Skip to content

Commit

Permalink
Flip .equals()
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrykuzmin committed Sep 3, 2020
1 parent 47baf5c commit 6692fc9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,7 @@ private static Correspondence<TestProcessManager, ProjectId> idCorrespondence()
return Correspondence.from(ProcessManagerRepositoryTest::hasId, "has ID");
}

private static boolean hasId(TestProcessManager projection, ProjectId id) {
return projection.id()
.equals(id);
private static boolean hasId(TestProcessManager processManager, ProjectId id) {
return id.equals(processManager.id());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ protected void setUp() {
.multitenant(getClass().getSimpleName())
.build();
super.setUp();
context.internalAccess().register(this.repository());
context.internalAccess()
.register(this.repository());
TestProjection.clearMessageDeliveryHistory();
}

Expand Down Expand Up @@ -338,7 +339,7 @@ void eventToDeleted() {
}

@SuppressWarnings("OverlyCoupledMethod")
// A complex test case with many test domain messages.
// A complex test case with many test domain messages.
@Test
@DisplayName("entity state update")
void entityState() throws Exception {
Expand Down Expand Up @@ -366,7 +367,8 @@ void entityState() throws Exception {
.build();
EntitySubscriberProjection.Repository repository =
new EntitySubscriberProjection.Repository();
BoundedContext context = BoundedContextBuilder.assumingTests().build();
BoundedContext context = BoundedContextBuilder.assumingTests()
.build();
context.internalAccess()
.register(repository);
EventEnvelope envelope = EventEnvelope.of(eventFactory.createEvent(changedEvent));
Expand All @@ -375,11 +377,13 @@ void entityState() throws Exception {
.newBuilder()
.setProjectId(id)
.setProjectName(projectCreated.getName())
.addTaskName(taskAdded.getTask().getTitle())
.addTaskName(taskAdded.getTask()
.getTitle())
.build();
Optional<EntitySubscriberProjection> projection = repository.find(id);
assertTrue(projection.isPresent());
assertEquals(expectedValue, projection.get().state());
assertEquals(expectedValue, projection.get()
.state());

context.close();
}
Expand Down Expand Up @@ -472,7 +476,9 @@ void emitRoutingFailedOnUnknownEvent() {
List<RoutingFailed> failures = monitor.routingFailures();
assertThat(failures.size()).isEqualTo(1);
RoutingFailed failure = failures.get(0);
assertThat(failure.getError().getMessage()).contains(repository().idClass().getName());
assertThat(failure.getError()
.getMessage()).contains(repository().idClass()
.getName());
}

@Nested
Expand Down Expand Up @@ -651,7 +657,8 @@ void updateColumns() {

// Check the column value is propagated to the entity state.
TestProjection entityWithColumns = afterMigration.next();
assertThat(entityWithColumns.state().getIdString()).isEqualTo(id.toString());
assertThat(entityWithColumns.state()
.getIdString()).isEqualTo(id.toString());
}

@Test
Expand Down Expand Up @@ -699,8 +706,10 @@ void archiveEntityViaMigration() {
repository().applyMigration(id, new MarkProjectionArchived<>());

Optional<TestProjection> found = repository().find(id);
Truth8.assertThat(found).isPresent();
assertThat(found.get().isArchived()).isTrue();
Truth8.assertThat(found)
.isPresent();
assertThat(found.get()
.isArchived()).isTrue();
}

@Test
Expand All @@ -713,8 +722,10 @@ void deleteEntityViaMigration() {
repository().applyMigration(id, new MarkProjectionDeleted<>());

Optional<TestProjection> found = repository().find(id);
Truth8.assertThat(found).isPresent();
assertThat(found.get().isDeleted()).isTrue();
Truth8.assertThat(found)
.isPresent();
assertThat(found.get()
.isDeleted()).isTrue();
}

@Test
Expand All @@ -727,7 +738,8 @@ void removeRecordViaMigration() {
repository().applyMigration(id, new RemoveProjectionFromStorage<>());

Optional<TestProjection> found = repository().find(id);
Truth8.assertThat(found).isEmpty();
Truth8.assertThat(found)
.isEmpty();
}

private static TargetFilters targetFilters(EntityColumn column, String value) {
Expand All @@ -749,6 +761,6 @@ private static Correspondence<TestProjection, ProjectId> idCorrespondence() {
}

private static boolean hasId(TestProjection projection, ProjectId id) {
return projection.id().equals(id);
return id.equals(projection.id());
}
}

0 comments on commit 6692fc9

Please sign in to comment.