code stringlengths 23 201k | docstring stringlengths 17 96.2k | func_name stringlengths 0 235 | language stringclasses 1
value | repo stringlengths 8 72 | path stringlengths 11 317 | url stringlengths 57 377 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
@Test
public void hasMessageThat_messageHasNullMessage_failure() {
expectFailure(
whenTesting ->
whenTesting.that(new NullPointerException("message")).hasMessageThat().isNull());
} | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasMessageThat_messageHasNullMessage_failure | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void hasMessageThat_nullMessageHasMessage_failure() {
NullPointerException npe = new NullPointerException(null);
expectFailure(whenTesting -> whenTesting.that(npe).hasMessageThat().isEqualTo("message"));
} | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasMessageThat_nullMessageHasMessage_failure | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void hasMessageThat_tooDeep_failure() {
Exception actual = new Exception("foobar");
AssertionError e =
expectFailure(
whenTesting -> whenTesting.that(actual).hasCauseThat().hasMessageThat().isNull());
assertFailureKeys(
e, "Attempt to assert about the message of a ... | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasMessageThat_tooDeep_failure | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void hasMessageThat_onNull() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that((Throwable) null).hasMessageThat());
assertFailureKeys(e, "Attempt to assert about the message of a null Throwable");
} | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasMessageThat_onNull | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void hasCauseThat_message() {
assertThat(new Exception("foobar", new IOException("barfoo")))
.hasCauseThat()
.hasMessageThat()
.isEqualTo("barfoo");
} | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasCauseThat_message | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void hasCauseThat_instanceOf() {
assertThat(new Exception("foobar", new IOException("barfoo")))
.hasCauseThat()
.isInstanceOf(IOException.class);
} | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasCauseThat_instanceOf | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void hasCauseThat_null() {
assertThat(new Exception("foobar")).hasCauseThat().isNull();
} | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasCauseThat_null | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void hasCauseThat_message_failure() {
Exception actual = new Exception("foobar", new IOException("barfoo"));
AssertionError e =
expectFailure(
whenTesting ->
whenTesting.that(actual).hasCauseThat().hasMessageThat().isEqualTo("message"));
assertFailureValue(... | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasCauseThat_message_failure | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void hasCauseThat_instanceOf_failure() {
Exception actual = new Exception("foobar", new IOException("barfoo"));
AssertionError e =
expectFailure(
whenTesting ->
whenTesting.that(actual).hasCauseThat().isInstanceOf(RuntimeException.class));
assertFailureValu... | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasCauseThat_instanceOf_failure | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void hasCauseThat_tooDeep_failure() {
Exception actual = new Exception("foobar");
AssertionError e =
expectFailure(
whenTesting -> whenTesting.that(actual).hasCauseThat().hasCauseThat().isNull());
assertFailureKeys(
e, "Attempt to assert about the cause of a null T... | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasCauseThat_tooDeep_failure | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void hasCauseThat_onNull() {
AssertionError e =
expectFailure(whenTesting -> whenTesting.that((Throwable) null).hasCauseThat());
assertFailureKeys(e, "Attempt to assert about the cause of a null Throwable");
} | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasCauseThat_onNull | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void hasCauseThat_deepNull_failure() {
Exception actual =
new Exception("foobar", new RuntimeException("barfoo", new IOException("buzz")));
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(actual)
... | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | hasCauseThat_deepNull_failure | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
@Test
public void inheritedMethodChainsSubject() {
NullPointerException expected = new NullPointerException("expected");
NullPointerException actual = new NullPointerException("actual");
AssertionError e = expectFailure(whenTesting -> whenTesting.that(actual).isEqualTo(expected));
assertErrorHasActual... | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | inheritedMethodChainsSubject | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
private static void assertErrorHasActualAsCause(Throwable actual, AssertionError failure) {
assertWithMessage("AssertionError's cause").that(failure.getCause()).isEqualTo(actual);
} | Tests for {@link Throwable} subjects.
@author Kurt Alfred Kluever | assertErrorHasActualAsCause | java | google/truth | core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/ThrowableSubjectTest.java | Apache-2.0 |
private static TypeToken<?> methodToReturnTypeToken(Method input) {
return TypeToken.of(Iterables.getOnlyElement(asList(input.getParameterTypes())));
} | Tests for the FEST-alike assertThat() entry point.
@author Christian Gruber (cgruber@israfil.net) | methodToReturnTypeToken | java | google/truth | core/src/test/java/com/google/common/truth/TruthAssertThatTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TruthAssertThatTest.java | Apache-2.0 |
@Test
public void staticAssertThatMethodsMatchStandardSubjectBuilderInstanceMethods() {
ImmutableSortedSet<TypeToken<?>> verbTypes =
FluentIterable.from(asList(StandardSubjectBuilder.class.getMethods()))
.filter(input -> input.getName().equals("that"))
.transform(TruthAssertThatTes... | Tests for the FEST-alike assertThat() entry point.
@author Christian Gruber (cgruber@israfil.net) | staticAssertThatMethodsMatchStandardSubjectBuilderInstanceMethods | java | google/truth | core/src/test/java/com/google/common/truth/TruthAssertThatTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/TruthAssertThatTest.java | Apache-2.0 |
public static EmployeeSubject assertThat(@Nullable Employee employee) {
return assertAbout(employees()).that(employee);
} | A <a href="https://github.com/google/truth">Truth</a> subject for {@link Employee}.
@author Kurt Alfred Kluever (kak@google.com) | assertThat | java | google/truth | core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | Apache-2.0 |
public static Factory<EmployeeSubject, Employee> employees() {
return EmployeeSubject::new;
} | A <a href="https://github.com/google/truth">Truth</a> subject for {@link Employee}.
@author Kurt Alfred Kluever (kak@google.com) | employees | java | google/truth | core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | Apache-2.0 |
public void isCeo() {
if (!actual.isCeo()) {
failWithActual(simpleFact("expected to be CEO"));
}
} | A <a href="https://github.com/google/truth">Truth</a> subject for {@link Employee}.
@author Kurt Alfred Kluever (kak@google.com) | isCeo | java | google/truth | core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | Apache-2.0 |
public void isNotCeo() {
if (actual.isCeo()) {
failWithActual(simpleFact("expected not to be CEO"));
}
} | A <a href="https://github.com/google/truth">Truth</a> subject for {@link Employee}.
@author Kurt Alfred Kluever (kak@google.com) | isNotCeo | java | google/truth | core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | Apache-2.0 |
public StringSubject name() {
return check("name()").that(actual.name());
} | A <a href="https://github.com/google/truth">Truth</a> subject for {@link Employee}.
@author Kurt Alfred Kluever (kak@google.com) | name | java | google/truth | core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | Apache-2.0 |
public StringSubject username() {
return check("username()").that(actual.username());
} | A <a href="https://github.com/google/truth">Truth</a> subject for {@link Employee}.
@author Kurt Alfred Kluever (kak@google.com) | username | java | google/truth | core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | Apache-2.0 |
public LongSubject id() {
return check("id()").that(actual.id());
} | A <a href="https://github.com/google/truth">Truth</a> subject for {@link Employee}.
@author Kurt Alfred Kluever (kak@google.com) | id | java | google/truth | core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | Apache-2.0 |
public ComparableSubject<Employee.Location> location() {
return check("location()").that(actual.location());
} | A <a href="https://github.com/google/truth">Truth</a> subject for {@link Employee}.
@author Kurt Alfred Kluever (kak@google.com) | location | java | google/truth | core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java | Apache-2.0 |
public void put(Employee employee) {
employees.put(employee.id(), employee);
} | In-memory implementation of {@link HrDatabase}, suitable for testing. | put | java | google/truth | core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java | Apache-2.0 |
@Override
public Employee get(long id) {
return employees.get(id);
} | In-memory implementation of {@link HrDatabase}, suitable for testing. | get | java | google/truth | core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java | Apache-2.0 |
@Override
public void relocate(long id, Location location) {
checkNotNull(location);
Employee old = get(id);
checkState(old != null, "No employee found with ID %s", id);
employees.put(id, Employee.create(old.username(), old.id(), old.name(), location, old.isCeo()));
} | In-memory implementation of {@link HrDatabase}, suitable for testing. | relocate | java | google/truth | core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java | Apache-2.0 |
@Override
public ImmutableSet<Employee> getByLocation(Location location) {
checkNotNull(location);
ImmutableSet.Builder<Employee> result = ImmutableSet.builder();
for (Employee employee : employees.values()) {
if (employee.location() == location) {
result.add(employee);
}
}
ret... | In-memory implementation of {@link HrDatabase}, suitable for testing. | getByLocation | java | google/truth | core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/extension/FakeHrDatabase.java | Apache-2.0 |
@Override public String getModuleName() {
return "com.google.common.truth.gwt.TruthTest";
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | getModuleName | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
public void testBuildClasses() {
String unused = new Inventory().toString(); // force invocation.
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testBuildClasses | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
public void testBoolean() {
assertThat(true).isTrue();
assertThat(false).isFalse();
try {
assertThat(true).isFalse();
} catch (AssertionError expected) {
return;
}
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testBoolean | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
@SuppressWarnings("TruthSelfEquals")
public void testInteger() {
assertThat(457923).isEqualTo(457923);
try {
assertThat(457923).isEqualTo(1);
} catch (AssertionError expected) {
return;
}
assert_().withMessage("Should have thrown an assertion error").fail();
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testInteger | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
public void testString() {
assertThat("blah").contains("ah");
assertThat("blah").startsWith("bl");
assertThat("blah").endsWith("ah");
try {
assertThat("blah").contains("foo");
} catch (AssertionError expected) {
return;
}
assert_().withMessage("Should have thrown an assertion er... | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testString | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
public void testString_match() {
assertThat("blah").matches("b[la]+h");
assertThat("blah").matches("^b.+h$");
assertThat("blah").containsMatch("ah");
assertThat("blah").containsMatch("b[la]{2}h");
assertThat("blah").doesNotMatch("ah");
assertThat("blah").doesNotContainMatch("oh");
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testString_match | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
public void testString_matchesFail() {
try {
assertThat("blah").matches("b[lu]+h");
} catch (AssertionError expected) {
return;
}
assert_().withMessage("Should have thrown an assertion error").fail();
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testString_matchesFail | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
public void testString_containsMatchFail() {
try {
assertThat("blah").containsMatch("o");
} catch (AssertionError expected) {
return;
}
assert_().withMessage("Should have thrown an assertion error").fail();
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testString_containsMatchFail | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
public void testString_doesNotMatchFail() {
try {
assertThat("blah").doesNotMatch("blah");
} catch (AssertionError expected) {
return;
}
assert_().withMessage("Should have thrown an assertion error").fail();
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testString_doesNotMatchFail | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
public void testString_doesNotContainMatchFail() {
try {
assertThat("blah").doesNotContainMatch("a");
} catch (AssertionError expected) {
return;
}
assert_().withMessage("Should have thrown an assertion error").fail();
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testString_doesNotContainMatchFail | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
public void testIterable() {
assertThat((Iterable<Integer>) asList(1, 2, 3)).containsExactly(1, 2, 3).inOrder();
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testIterable | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
public void testCollection() {
assertThat((Collection<Integer>) asList(1, 2, 3)).containsExactly(1, 2, 3).inOrder();
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testCollection | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
public void testList() {
assertThat(asList(1, 2, 3)).containsExactly(1, 2, 3).inOrder();
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testList | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
public void testObjectArray() {
Set<?>[] setOfString = {new HashSet<String>(asList("foo", "bar", "bash"))};
assertThat(setOfString).asList().contains(new HashSet<String>(asList("foo", "bar", "bash")));
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testObjectArray | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
@SuppressWarnings("IsInstanceIterable") // test of an intentionally trivially true assertion
public void testDefault() {
assertThat(new Object()).isNotNull();
assertThat(new ArrayList<String>()).isInstanceOf(AbstractList.class);
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testDefault | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
public void testLegacyAssert_() {
assert_().that(new Object()).isNotNull();
assert_().that(new ArrayList<String>()).isInstanceOf(AbstractList.class);
} | Test of Truth under GWT - should be enough tests here to force compilation of all Subject
implementations.
@author Christian Gruber (cgruber@israfil.net) | testLegacyAssert_ | java | google/truth | core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | https://github.com/google/truth/blob/master/core/src/test/java/com/google/common/truth/gwt/TruthGwtTest.java | Apache-2.0 |
static Factory<LiteProtoSubject, MessageLite> liteProtos() {
return LiteProtoSubjectFactory.INSTANCE;
} | Returns a {@code Subject.Factory} for {@link MessageLite} subjects which you can use to assert
things about Lite Protobuf properties. | liteProtos | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | Apache-2.0 |
static String getTrimmedToString(@Nullable MessageLite messageLite) {
String subjectString = String.valueOf(messageLite);
String trimmedSubjectString = subjectString.trim();
if (trimmedSubjectString.startsWith("# ")) {
String objectToString =
String.format(
"# %s@%s",
... | Returns a {@code Subject.Factory} for {@link MessageLite} subjects which you can use to assert
things about Lite Protobuf properties. | getTrimmedToString | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | Apache-2.0 |
@Override
protected String actualCustomStringRepresentation() {
return actualCustomStringRepresentationForProtoPackageMembersToCall();
} | Returns a {@code Subject.Factory} for {@link MessageLite} subjects which you can use to assert
things about Lite Protobuf properties. | actualCustomStringRepresentation | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | Apache-2.0 |
final String actualCustomStringRepresentationForProtoPackageMembersToCall() {
return getTrimmedToString(actual);
} | Returns a {@code Subject.Factory} for {@link MessageLite} subjects which you can use to assert
things about Lite Protobuf properties. | actualCustomStringRepresentationForProtoPackageMembersToCall | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | Apache-2.0 |
@Override
public void isEqualTo(@Nullable Object expected) {
// TODO(user): Do better here when MessageLite descriptors are available.
if (Objects.equals(actual, expected)) {
return;
}
if (actual == null || expected == null) {
super.isEqualTo(expected);
} else if (actual.getClass() !=... | Checks whether the MessageLite is equivalent to the argument, using the standard equals()
implementation. | isEqualTo | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | Apache-2.0 |
@Deprecated
public void isEqualTo(MessageLite.@Nullable Builder builder) {
isEqualTo((Object) builder);
} | @deprecated A Builder can never compare equal to a MessageLite instance. Use {@code build()},
or {@code buildPartial()} on the argument to get a MessageLite for comparison instead. Or,
if you are passing {@code null}, use {@link #isNull()}. | isEqualTo | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | Apache-2.0 |
@Override
public void isNotEqualTo(@Nullable Object expected) {
if (Objects.equals(actual, expected)) {
if (actual == null) {
super.isNotEqualTo(expected);
} else {
failWithoutActual(
simpleFact(
lenientFormat(
"Not true that protos are d... | @deprecated A Builder can never compare equal to a MessageLite instance. Use {@code build()},
or {@code buildPartial()} on the argument to get a MessageLite for comparison instead. Or,
if you are passing {@code null}, use {@link #isNull()}. | isNotEqualTo | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | Apache-2.0 |
@Deprecated
public void isNotEqualTo(MessageLite.@Nullable Builder builder) {
isNotEqualTo((Object) builder);
} | @deprecated A Builder will never compare equal to a MessageLite instance. Use {@code build()},
or {@code buildPartial()} on the argument to get a MessageLite for comparison instead. Or,
if you are passing {@code null}, use {@link #isNotNull()}. | isNotEqualTo | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | Apache-2.0 |
public void isEqualToDefaultInstance() {
if (actual == null) {
failWithoutActual(
simpleFact(
lenientFormat(
"Not true that <%s> is a default proto instance. It is null.",
actualCustomStringRepresentationForProtoPackageMembersToCall())));
} else ... | Checks whether the subject is a {@link MessageLite} with no fields set. | isEqualToDefaultInstance | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | Apache-2.0 |
public void isNotEqualToDefaultInstance() {
if (actual != null && actual.equals(actual.getDefaultInstanceForType())) {
failWithoutActual(
simpleFact(
lenientFormat(
"Not true that (%s) <%s> is not a default proto instance. It has no set values.",
act... | Checks whether the subject is not equivalent to a {@link MessageLite} with no fields set. | isNotEqualToDefaultInstance | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | Apache-2.0 |
public void hasAllRequiredFields() {
if (!actual.isInitialized()) {
// MessageLite doesn't support reflection so this is the best we can do.
failWithoutActual(
simpleFact("expected to have all required fields set"),
fact("but was", actualCustomStringRepresentationForProtoPackageMembe... | Checks whether the subject has all required fields set. Cannot fail for a proto built with
{@code build()}, which itself fails if required fields aren't set. | hasAllRequiredFields | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | Apache-2.0 |
public IntegerSubject serializedSize() {
return check("getSerializedSize()").that(actual.getSerializedSize());
} | Returns an {@link IntegerSubject} on the serialized size of the MessageLite.
<p>Assertions can then be changed on the serialized size, to support checks such as {@code
assertThat(myProto).serializedSize().isAtLeast(16)}, etc. | serializedSize | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | Apache-2.0 |
@Override
public LiteProtoSubject createSubject(
FailureMetadata failureMetadata, @Nullable MessageLite messageLite) {
return new LiteProtoSubject(failureMetadata, messageLite);
} | Returns an {@link IntegerSubject} on the serialized size of the MessageLite.
<p>Assertions can then be changed on the serialized size, to support checks such as {@code
assertThat(myProto).serializedSize().isAtLeast(16)}, etc. | createSubject | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java | Apache-2.0 |
public static LiteProtoSubject assertThat(@Nullable MessageLite messageLite) {
return assertAbout(liteProtos()).that(messageLite);
} | A set of static methods to begin a Truth assertion chain for the lite version of protocol
buffers.
<p>This class implements a subset of what {@code ProtoTruth} provides, so if you are already
using {@code ProtoTruth}, you should not import this class. {@code LiteProtoTruth} is only useful
if you cannot depend on {@cod... | assertThat | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java | Apache-2.0 |
public static Subject.Factory<LiteProtoSubject, MessageLite> liteProtos() {
return LiteProtoSubject.liteProtos();
} | A set of static methods to begin a Truth assertion chain for the lite version of protocol
buffers.
<p>This class implements a subset of what {@code ProtoTruth} provides, so if you are already
using {@code ProtoTruth}, you should not import this class. {@code LiteProtoTruth} is only useful
if you cannot depend on {@cod... | liteProtos | java | google/truth | extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java | Apache-2.0 |
public static Builder newBuilder() {
return new AutoValue_LiteProtoSubjectTest_Config.Builder();
} | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | newBuilder | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
// Missing a required_int field.
TestMessageLite2WithRequiredFields withoutRequiredFields =
TestMessageLite2WithRequiredFields.newBuilder().setOptionalString("foo").buildPartial();
Config proto2Config =
Config.newBuilde... | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | data | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
private LiteProtoSubject expectThat(@Nullable MessageLite m) {
return expect.about(LiteProtoTruth.liteProtos()).that(m);
} | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | expectThat | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
private Subject expectThat(@Nullable Object o) {
return expect.that(o);
} | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | expectThat | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
@Test
public void testSubjectMethods() {
expectThat(config.nonEmptyMessage()).isSameInstanceAs(config.nonEmptyMessage());
expectThat(config.nonEmptyMessage().toBuilder()).isNotSameInstanceAs(config.nonEmptyMessage());
expectThat(config.nonEmptyMessage()).isInstanceOf(MessageLite.class);
expectThat(co... | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | testSubjectMethods | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
@Test
public void testIsEqualTo_success() {
expectThat(null).isEqualTo(null);
expectThat(null).isNull();
expectThat(config.nonEmptyMessage()).isEqualTo(config.nonEmptyMessage());
expectThat(config.nonEmptyMessage()).isEqualTo(config.equivalentNonEmptyMessage());
expectThat(config.nonEmptyMessage(... | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | testIsEqualTo_success | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
@Test
public void testIsEqualTo_failure() {
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(config.nonEmptyMessage())
.isEqualTo(config.nonEmptyMessageOfOtherValue()));
expectRegex(e, ".*expected:.*\"foo\".*");
... | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | testIsEqualTo_failure | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
@Test
public void testHasAllRequiredFields_success() {
expectThat(config.nonEmptyMessage()).hasAllRequiredFields();
} | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | testHasAllRequiredFields_success | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
@Test
public void testHasAllRequiredFields_failures() {
if (!config.messageWithoutRequiredFields().isPresent()) {
return;
}
AssertionError e =
expectFailure(
whenTesting ->
whenTesting
.that(config.messageWithoutRequiredFields().get())
... | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | testHasAllRequiredFields_failures | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
@Test
public void testDefaultInstance_success() {
expectThat(config.defaultInstance()).isEqualToDefaultInstance();
expectThat(config.defaultInstanceOfOtherType()).isEqualToDefaultInstance();
expectThat(config.nonEmptyMessage().getDefaultInstanceForType()).isEqualToDefaultInstance();
expectThat(null).... | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | testDefaultInstance_success | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
@Test
public void testDefaultInstance_failure() {
AssertionError e =
expectFailure(
whenTesting -> whenTesting.that(config.nonEmptyMessage()).isEqualToDefaultInstance());
expectRegex(
e,
"Not true that <.*optional_int:\\s*3.*> is a default proto instance\\.\\s*"
... | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | testDefaultInstance_failure | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
@Test
public void testSerializedSize_success() {
int size = config.nonEmptyMessage().getSerializedSize();
expectThat(config.nonEmptyMessage()).serializedSize().isEqualTo(size);
expectThat(config.defaultInstance()).serializedSize().isEqualTo(0);
} | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | testSerializedSize_success | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
@Test
public void testSerializedSize_failure() {
int size = config.nonEmptyMessage().getSerializedSize();
AssertionError e =
expectFailure(
whenTesting ->
whenTesting.that(config.nonEmptyMessage()).serializedSize().isGreaterThan(size));
assertThat(e).factValue("value o... | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | testSerializedSize_failure | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
private void expectRegex(AssertionError e, String regex) {
expect.that(e).hasMessageThat().matches(Pattern.compile(regex, Pattern.DOTALL));
} | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | expectRegex | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
private void expectNoRegex(AssertionError e, String regex) {
expect.that(e).hasMessageThat().doesNotMatch(Pattern.compile(regex, Pattern.DOTALL));
} | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | expectNoRegex | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
private static AssertionError expectFailure(
SimpleSubjectBuilderCallback<LiteProtoSubject, MessageLite> assertionCallback) {
return expectFailureAbout(liteProtos(), assertionCallback);
} | We run (almost) all the tests for both proto2 and proto3 implementations. This class organizes
the parameters much more cleanly than a raw Object[]. | expectFailure | java | google/truth | extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | https://github.com/google/truth/blob/master/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java | Apache-2.0 |
static FieldDescriptor typeUrlFieldDescriptor() {
return TYPE_URL_FIELD_DESCRIPTOR;
} | Helper methods for working with Any protos. | typeUrlFieldDescriptor | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | Apache-2.0 |
static SubScopeId typeUrlSubScopeId() {
return TYPE_URL_SUB_SCOPE_ID;
} | Helper methods for working with Any protos. | typeUrlSubScopeId | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | Apache-2.0 |
static FieldDescriptor valueFieldDescriptor() {
return VALUE_FIELD_DESCRIPTOR;
} | Helper methods for working with Any protos. | valueFieldDescriptor | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | Apache-2.0 |
static SubScopeId valueSubScopeId() {
return VALUE_SUB_SCOPE_ID;
} | Helper methods for working with Any protos. | valueSubScopeId | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | Apache-2.0 |
static TypeRegistry defaultTypeRegistry() {
return DEFAULT_TYPE_REGISTRY;
} | Helper methods for working with Any protos. | defaultTypeRegistry | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | Apache-2.0 |
static ExtensionRegistry defaultExtensionRegistry() {
return DEFAULT_EXTENSION_REGISTRY;
} | Helper methods for working with Any protos. | defaultExtensionRegistry | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | Apache-2.0 |
static Optional<Message> unpack(
Message any, TypeRegistry typeRegistry, ExtensionRegistry extensionRegistry) {
Preconditions.checkArgument(
any.getDescriptorForType().equals(Any.getDescriptor()),
"Expected type google.protobuf.Any, but was: %s",
any.getDescriptorForType().getFullName(... | Unpack an `Any` proto using the given TypeRegistry and ExtensionRegistry. | unpack | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/AnyUtils.java | Apache-2.0 |
@Memoized
Object actualOrExpected() {
return actual().or(expected()).get();
} | Returns {@code actual().get()}, or {@code expected().get()}, whichever is available. | actualOrExpected | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
@Memoized
@Override
Iterable<? extends RecursableDiffEntity> childEntities() {
return ImmutableList.copyOf(
Iterables.concat(breakdown().asSet(), unknownsBreakdown().asSet()));
} | Returns {@code actual().get()}, or {@code expected().get()}, whichever is available. | childEntities | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
@Override
final void printContents(boolean includeMatches, String fieldPrefix, StringBuilder sb) {
if (!includeMatches && isMatched()) {
return;
}
fieldPrefix = newFieldPrefix(fieldPrefix, fieldName());
switch (result()) {
case ADDED:
sb.append("added: ").append(fi... | Returns {@code actual().get()}, or {@code expected().get()}, whichever is available. | printContents | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
@Override
final boolean isContentEmpty() {
return false;
} | Returns {@code actual().get()}, or {@code expected().get()}, whichever is available. | isContentEmpty | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
static SingularField ignored(String fieldName) {
return newBuilder()
.setFieldName(fieldName)
.setResult(Result.IGNORED)
// Ignored fields don't need a customized proto printer.
.setProtoPrinter(TextFormat.printer())
.build();
} | Returns {@code actual().get()}, or {@code expected().get()}, whichever is available. | ignored | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
static Builder newBuilder() {
return new AutoValue_DiffResult_SingularField.Builder();
} | Returns {@code actual().get()}, or {@code expected().get()}, whichever is available. | newBuilder | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
@Memoized
@Override
Iterable<? extends RecursableDiffEntity> childEntities() {
return breakdown().asSet();
} | A detailed breakdown of the comparison between the messages. Present iff {@code actual()}
and {@code expected()} are {@link Message}s. | childEntities | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
@Memoized
boolean isMessage() {
return actual().orNull() instanceof Message || expected().orNull() instanceof Message;
} | Returns true if actual() and expected() contain Message types. | isMessage | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
private static String indexed(String fieldPrefix, Optional<Integer> fieldIndex) {
String index = fieldIndex.isPresent() ? fieldIndex.get().toString() : "?";
return fieldPrefix + "[" + index + "]";
} | Returns true if actual() and expected() contain Message types. | indexed | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
@Override
final void printContents(boolean includeMatches, String fieldPrefix, StringBuilder sb) {
printContentsForRepeatedField(
/* includeSelfAlways = */ false, includeMatches, fieldPrefix, sb);
} | Returns true if actual() and expected() contain Message types. | printContents | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
final void printContentsForRepeatedField(
boolean includeSelfAlways, boolean includeMatches, String fieldPrefix, StringBuilder sb) {
if (!includeSelfAlways && !includeMatches && isMatched()) {
return;
}
switch (result()) {
case ADDED:
sb.append("added: ... | Returns true if actual() and expected() contain Message types. | printContentsForRepeatedField | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
@Override
final boolean isContentEmpty() {
return false;
} | Returns true if actual() and expected() contain Message types. | isContentEmpty | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
static Builder newBuilder() {
return new AutoValue_DiffResult_RepeatedField_PairResult.Builder();
} | Returns true if actual() and expected() contain Message types. | newBuilder | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
@Memoized
@Override
Iterable<? extends RecursableDiffEntity> childEntities() {
return pairResults();
} | Pairs of elements which were diffed against each other. | childEntities | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
@Override
final void printContents(boolean includeMatches, String fieldPrefix, StringBuilder sb) {
fieldPrefix = newFieldPrefix(fieldPrefix, fieldDescriptor().getName());
for (PairResult pairResult : pairResults()) {
pairResult.printContentsForRepeatedField(
/* includeSelfAlways = */... | Pairs of elements which were diffed against each other. | printContents | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
@Override
final boolean isContentEmpty() {
return pairResults().isEmpty();
} | Pairs of elements which were diffed against each other. | isContentEmpty | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
static Builder newBuilder() {
return new AutoValue_DiffResult_RepeatedField.Builder();
} | Pairs of elements which were diffed against each other. | newBuilder | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
@CanIgnoreReturnValue
final Builder addPairResult(PairResult pairResult) {
pairResultsBuilder().add(pairResult);
return this;
} | Pairs of elements which were diffed against each other. | addPairResult | java | google/truth | extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | https://github.com/google/truth/blob/master/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/DiffResult.java | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.