Skip to content

Commit

Permalink
fixed compile errors regarding signature change of Metadata.of
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch.io>
  • Loading branch information
thjaeckle committed Jan 28, 2021
1 parent 7191ed7 commit 65f2c4d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 26 deletions.
Expand Up @@ -336,7 +336,7 @@ private static Metadata readAsMetadata(final Document document) {
final long policyRevision = Optional.ofNullable(document.getLong(FIELD_POLICY_REVISION)).orElse(0L);
final String nullableTimestamp = document.getEmbedded(List.of(FIELD_SORTING, FIELD_MODIFIED), String.class);
final Instant modified = Optional.ofNullable(nullableTimestamp).map(Instant::parse).orElse(null);
return Metadata.of(thingId, thingRevision, policyId, policyRevision, modified);
return Metadata.of(thingId, thingRevision, policyId, policyRevision, modified, null);
}

}
Expand Up @@ -103,7 +103,7 @@ public static ThingWriteModel toWriteModel(final JsonObject thing,
final ThingId thingId = ThingId.of(extractedThing);
final long thingRevision = thing.getValueOrThrow(Thing.JsonFields.REVISION);
final PolicyId nullablePolicyId = thing.getValue(Thing.JsonFields.POLICY_ID).map(PolicyId::of).orElse(null);
final Metadata metadata = Metadata.of(thingId, thingRevision, nullablePolicyId, policyRevision);
final Metadata metadata = Metadata.of(thingId, thingRevision, nullablePolicyId, policyRevision, null);

// hierarchical values for sorting
final BsonValue thingCopyForSorting = JsonToBson.convert(pruneArrays(thing, maxArraySize));
Expand Down
Expand Up @@ -108,7 +108,7 @@ private boolean isInsideToleranceWindow(final Metadata metadata, final Instant t
}

private static Metadata dummyMetadata() {
return Metadata.of(ThingId.dummy(), 0L, PolicyId.dummy(), 0L);
return Metadata.of(ThingId.dummy(), 0L, PolicyId.dummy(), 0L, null);
}

private Source<Metadata, NotUsed> filterForInconsistency(final Pair<Metadata, Metadata> pair) {
Expand Down
Expand Up @@ -93,8 +93,8 @@ public void sudoCount() {

@Test
public void sudoStreamMetadata() {
final Metadata metadata1 = Metadata.of(THING1_ID, 1L, PolicyId.of(THING1_ID), 0L, TIMESTAMP1);
final Metadata metadata2 = Metadata.of(THING2_ID, 2L, PolicyId.of(THING2_ID), 0L, TIMESTAMP2);
final Metadata metadata1 = Metadata.of(THING1_ID, 1L, PolicyId.of(THING1_ID), 0L, TIMESTAMP1, null);
final Metadata metadata2 = Metadata.of(THING2_ID, 2L, PolicyId.of(THING2_ID), 0L, TIMESTAMP2, null);
assertThat(waitFor(readPersistence.sudoStreamMetadata(ThingId.dummy())))
.containsExactly(metadata1, metadata2);

Expand Down
Expand Up @@ -60,22 +60,22 @@ public void mergeMetadataStreams() {
final Duration toleranceWindow = Duration.ofHours(1L);

final Source<Metadata, NotUsed> persisted = Source.from(List.of(
Metadata.of(ThingId.of("x:0-only-persisted"), 1L, null, 0L),
Metadata.of(ThingId.of("x:2-within-tolerance"), 3L, null, 0L),
Metadata.of(ThingId.of("x:3-revision-mismatch"), 3L, PolicyId.of("x:3"), 0L),
Metadata.of(ThingId.of("x:4-policy-id-mismatch"), 3L, PolicyId.of("x:4"), 0L),
Metadata.of(ThingId.of("x:5-policy-revision-mismatch"), 3L, PolicyId.of("x:5"), 0L),
Metadata.of(ThingId.of("x:6-all-up-to-date"), 3L, PolicyId.of("x:6"), 0L),
Metadata.of(ThingId.of("x:7-policy-deleted"), 7L, PolicyId.of("x:7"), 0L)
Metadata.of(ThingId.of("x:0-only-persisted"), 1L, null, 0L, null),
Metadata.of(ThingId.of("x:2-within-tolerance"), 3L, null, 0L, null),
Metadata.of(ThingId.of("x:3-revision-mismatch"), 3L, PolicyId.of("x:3"), 0L, null),
Metadata.of(ThingId.of("x:4-policy-id-mismatch"), 3L, PolicyId.of("x:4"), 0L, null),
Metadata.of(ThingId.of("x:5-policy-revision-mismatch"), 3L, PolicyId.of("x:5"), 0L, null),
Metadata.of(ThingId.of("x:6-all-up-to-date"), 3L, PolicyId.of("x:6"), 0L, null),
Metadata.of(ThingId.of("x:7-policy-deleted"), 7L, PolicyId.of("x:7"), 0L, null)
));

final Source<Metadata, NotUsed> indexed = Source.from(List.of(
Metadata.of(ThingId.of("x:1-only-indexed"), 1L, null, 0L),
Metadata.of(ThingId.of("x:2-within-tolerance"), 1L, null, 0L, Instant.now()),
Metadata.of(ThingId.of("x:3-revision-mismatch"), 2L, PolicyId.of("x:3"), 1L),
Metadata.of(ThingId.of("x:4-policy-id-mismatch"), 3L, PolicyId.of("x:mismatched"), 0L),
Metadata.of(ThingId.of("x:5-policy-revision-mismatch"), 3L, PolicyId.of("x:5"), 3L),
Metadata.of(ThingId.of("x:6-all-up-to-date"), 5L, PolicyId.of("x:6"), 6L)
Metadata.of(ThingId.of("x:1-only-indexed"), 1L, null, 0L, null),
Metadata.of(ThingId.of("x:2-within-tolerance"), 1L, null, 0L, Instant.now(), null),
Metadata.of(ThingId.of("x:3-revision-mismatch"), 2L, PolicyId.of("x:3"), 1L, null),
Metadata.of(ThingId.of("x:4-policy-id-mismatch"), 3L, PolicyId.of("x:mismatched"), 0L, null),
Metadata.of(ThingId.of("x:5-policy-revision-mismatch"), 3L, PolicyId.of("x:5"), 3L, null),
Metadata.of(ThingId.of("x:6-all-up-to-date"), 5L, PolicyId.of("x:6"), 6L, null)
));

new TestKit(actorSystem) {{
Expand Down
Expand Up @@ -199,7 +199,7 @@ private List<AbstractWriteModel> generateWriteModels(final List<TestProbe> probe
final PolicyId policyId = i % 4 < 2 ? null : PolicyId.of("policy", String.valueOf(i));
final long policyRevision = i * 100;
final Metadata metadata =
Metadata.of(thingId, thingRevision, policyId, policyRevision, probes.get(i).ref());
Metadata.of(thingId, thingRevision, policyId, policyRevision, null, probes.get(i).ref());
if (i % 2 == 0) {
writeModels.add(ThingDeleteModel.of(metadata));
} else {
Expand Down
Expand Up @@ -69,11 +69,8 @@
import akka.actor.ActorSystem;
import akka.cluster.pubsub.DistributedPubSubMediator;
import akka.japi.Pair;
import akka.stream.ActorMaterializer;
import akka.stream.Materializer;
import akka.stream.SourceRef;
import akka.stream.javadsl.Flow;
import akka.stream.javadsl.Sink;
import akka.stream.javadsl.Source;
import akka.stream.javadsl.StreamRefs;
import akka.testkit.javadsl.TestKit;
Expand All @@ -97,7 +94,7 @@ public final class BackgroundSyncActorTest {
);
private static final List<Metadata> THINGS_INDEXED =
KNOWN_IDs.stream()
.map(id -> Metadata.of(ThingId.of(id), REVISION_INDEXED, PolicyId.of(id), REVISION_INDEXED))
.map(id -> Metadata.of(ThingId.of(id), REVISION_INDEXED, PolicyId.of(id), REVISION_INDEXED, null))
.collect(Collectors.toList());
private static final List<StreamedSnapshot> THINGS_PERSISTED = KNOWN_IDs.stream()
.map(id -> createStreamedSnapshot(id, REVISION_PERSISTED))
Expand Down Expand Up @@ -167,7 +164,7 @@ public void providesHealthWarningWhenSyncStreamFails() {

@Test
public void providesHealthWarningWhenSameThingIsSynchronizedTwice() {
final Metadata indexedThingMetadata = Metadata.of(THING_ID, 2, null, null);
final Metadata indexedThingMetadata = Metadata.of(THING_ID, 2, null, null, null);
final long persistedRevision = indexedThingMetadata.getThingRevision() + 1;

new TestKit(actorSystem) {{
Expand Down Expand Up @@ -201,9 +198,9 @@ public void providesHealthWarningWhenSameThingIsSynchronizedTwice() {

@Test
public void staysHealthyWhenSameThingIsSynchronizedWithOtherRevision() {
final Metadata indexedThingMetadata = Metadata.of(THING_ID, 2, null, null);
final Metadata indexedThingMetadata = Metadata.of(THING_ID, 2, null, null, null);
final long persistedRevision = indexedThingMetadata.getThingRevision() + 1;
final Metadata nextThingMetadata = Metadata.of(THING_ID, persistedRevision, null, null);
final Metadata nextThingMetadata = Metadata.of(THING_ID, persistedRevision, null, null, null);
final long nextRevision = nextThingMetadata.getThingRevision() + 1;

new TestKit(actorSystem) {{
Expand Down

0 comments on commit 65f2c4d

Please sign in to comment.