Line data Source code
1 : // Copyright (C) 2019 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server.fixes.testing; 16 : 17 : import static com.google.common.truth.Truth.assertAbout; 18 : import static com.google.gerrit.server.fixes.testing.GitEditSubject.gitEdits; 19 : import static com.google.gerrit.truth.ListSubject.elements; 20 : 21 : import com.google.common.truth.FailureMetadata; 22 : import com.google.common.truth.StringSubject; 23 : import com.google.common.truth.Subject; 24 : import com.google.gerrit.server.fixes.FixCalculator.FixResult; 25 : import com.google.gerrit.truth.ListSubject; 26 : import org.eclipse.jgit.diff.Edit; 27 : 28 : public class FixResultSubject extends Subject { 29 : public static FixResultSubject assertThat(FixResult fixResult) { 30 1 : return assertAbout(FixResultSubject::new).that(fixResult); 31 : } 32 : 33 : private final FixResult fixResult; 34 : 35 : private FixResultSubject(FailureMetadata failureMetadata, FixResult fixResult) { 36 1 : super(failureMetadata, fixResult); 37 1 : this.fixResult = fixResult; 38 1 : } 39 : 40 : public StringSubject text() { 41 1 : isNotNull(); 42 1 : return check("text").that(fixResult.text.getString(0, fixResult.text.size(), false)); 43 : } 44 : 45 : public ListSubject<GitEditSubject, Edit> edits() { 46 1 : isNotNull(); 47 1 : return check("edits").about(elements()).thatCustom(fixResult.edits, gitEdits()); 48 : } 49 : }