Skip to content

Commit

Permalink
review: code format and use predefined constant;
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Maute <stefan.maute@bosch.io>
  • Loading branch information
Stefan Maute committed Mar 21, 2022
1 parent 61fbef3 commit 55f85e3
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ public final class SearchConsistencyIT {
public void setup() {
mongoClient = provideClientWrapper();
final var config = ConfigFactory.load("test");
final var updaterConfig = DefaultUpdaterConfig.of(ConfigFactory.load("updater-test"));
final var updaterConfig =
DefaultUpdaterConfig.of(ConfigFactory.load("updater-test"));
actorSystem = ActorSystem.create("AkkaTestSystem", config);
final var pubSubMediator = DistributedPubSub.get(actorSystem).mediator();
final ActorRef changeQueue1 = createChangeQueue(actorSystem);
Expand All @@ -140,7 +141,6 @@ public void setup() {
updater2 = createSearchUpdaterShardRegion(changeQueue2, pubSubMediator, updaterConfig);
updaterStream1 = createSearchUpdaterStream(updaterConfig, updater1, changeQueue1);
updaterStream2 = createSearchUpdaterStream(updaterConfig, updater2, changeQueue2);

}

@After()
Expand All @@ -157,6 +157,7 @@ private static DittoMongoClient provideClientWrapper() {

private static ActorRef createChangeQueue(final ActorRefFactory actorSystem) {
final var changeQueueProps = ChangeQueueActor.props();

return actorSystem.actorOf(changeQueueProps);
}

Expand All @@ -168,6 +169,7 @@ private SearchUpdaterStream createSearchUpdaterStream(final UpdaterConfig update
final var db = mongoClient.getDefaultDatabase();
final var blockedNamespaces = BlockedNamespaces.of(actorSystem);
final var updateMapper = SearchUpdateMapper.get(actorSystem);

return SearchUpdaterStream.of(updaterConfig, actorSystem, thingsShard, policiesShard, updaterShard, changeQueue,
db, blockedNamespaces, updateMapper);
}
Expand All @@ -181,6 +183,7 @@ private ActorRef createSearchUpdaterShardRegion(final ActorRef changeQueue,
final var updater = actorSystem.actorOf(updaterProps, THING_ID.toString() + Math.random());

final var shardMockProps = UpdaterShardMock.props(updater);

return actorSystem.actorOf(shardMockProps);
}

Expand All @@ -195,11 +198,13 @@ public void assertConsistencyInCaseOfConflict() {
.newObjectBuilder().set("char", EXPECTED_CHAR).set("number", EXPECTED_NUMBER).build())));
probe.send(updater2, getThingEvent(ThingsModelFactory.newAttributes(JsonFactory
.newObjectBuilder().set("number", EXPECTED_NUMBER).set("char", EXPECTED_CHAR).build())));

assertSearchPersisted(Duration.ofSeconds(10));
}

private static ThingEvent<?> getThingEvent(final Attributes attributes) {
final var dittoHeaders = getDittoHeadersWithSearchPersistedAck();

return AttributesModified.of(THING_ID, attributes, REVISION, MODIFIED, dittoHeaders, null);
}

Expand Down Expand Up @@ -240,12 +245,13 @@ private static AbstractWriteModel getRecoveryWriteModel() {
.append(PersistenceConstants.FIELD_GLOBAL_READ, new BsonString("integration:test"))
.append(PersistenceConstants.FIELD_SORTING, new BsonDocument())
.append(PersistenceConstants.FIELD_INTERNAL, new BsonArray());

return ThingWriteModel.of(metadata, thingDocument);
}

private static boolean documentIsExpected(final Map<String, Object> actual) {
final var sorting = (Document) actual.get(PersistenceConstants.FIELD_SORTING);
final var sortingAttributes = (Document) sorting.get("attributes");
final var sortingAttributes = (Document) sorting.get(PersistenceConstants.FIELD_ATTRIBUTES);
final var internal = (List<Document>) actual.get(PersistenceConstants.FIELD_INTERNAL);

return actual.get(PersistenceConstants.FIELD_ID).equals(THING_ID.toString()) &&
Expand Down Expand Up @@ -340,7 +346,6 @@ public Receive createReceive() {

private static final class ThingShardMock extends AbstractActor {


private ThingShardMock() {
}

Expand All @@ -365,7 +370,6 @@ private void sendSudoRetrieveThingResponse(final WithDittoHeaders srt) {

private static final class PolicyShardMock extends AbstractActor {


private PolicyShardMock() {
}

Expand All @@ -381,7 +385,8 @@ public Receive createReceive() {
}

private void sendSudoRetrievePolicyResponse(final WithDittoHeaders srt) {
final var response = SudoRetrievePolicyResponse.of(POLICY_ID, POLICY, srt.getDittoHeaders());
final var response =
SudoRetrievePolicyResponse.of(POLICY_ID, POLICY, srt.getDittoHeaders());
getSender().tell(response, getSelf());
}

Expand Down

0 comments on commit 55f85e3

Please sign in to comment.