Add missing chained subject methods in EmployeeSubject
And remove resolved/outdated comments
Fixes
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/truth/pull/909 from SimonMarquis:patch-2
@@ -18,7 +18,10 @@ package com.google.common.truth.extension;
import static com.google.common.truth.Fact.simpleFact;
import static com.google.common.truth.Truth.assertAbout;
+import com.google.common.truth.ComparableSubject;
import com.google.common.truth.FailureMetadata;
+import com.google.common.truth.LongSubject;
+import com.google.common.truth.StringSubject;
import com.google.common.truth.Subject;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -53,19 +56,19 @@ public final class EmployeeSubject extends Subject {
// User-defined test assertion SPI below this point
public void hasName(String name) {
- check("name()").that(actual.name()).isEqualTo(name);
+ name().isEqualTo(name);
}
public void hasUsername(String username) {
- check("username()").that(actual.username()).isEqualTo(username);
+ username().isEqualTo(username);
}
public void hasId(long id) {
- check("id()").that(actual.id()).isEqualTo(id);
+ id().isEqualTo(id);
}
public void hasLocation(Employee.Location location) {
- check("location()").that(actual.location()).isEqualTo(location);
+ location().isEqualTo(location);
}
public void isCeo() {
@@ -80,7 +83,21 @@ public final class EmployeeSubject extends Subject {
}
}
- // TODO(kak): Add methods that return other subjects. E.g.,
- // public StringSubject username() {}
- // public IterableSubject languages() {}
+ // Chained subjects methods below this point
+
+ public StringSubject name() {
+ return check("name()").that(actual.name());
+ }
+
+ public StringSubject username() {
+ return check("username()").that(actual.username());
+ }
+
+ public LongSubject id() {
+ return check("id()").that(actual.id());
+ }
+
+ public ComparableSubject<Employee.Location> location() {
+ return check("location()").that(actual.location());
+ }
}
