use of org.atlasapi.messaging.v3.ContentEquivalenceAssertionMessage in project atlas-deer by atlasapi.
the class ContentEquivalenceAssertionLegacyTransformer method transform.
public EquivalenceAssertionMessage transform(ContentEquivalenceAssertionMessage leg) {
String mid = leg.getMessageId();
Timestamp ts = leg.getTimestamp();
ResourceRef subj = LegacyTransformer.resourceRef(leg.getEntityId(), leg.getEntitySource(), leg.getEntityType(), leg.getTimestamp());
Set<ResourceRef> adjacents = toResourceRef(leg);
Set<Publisher> srcs = ImmutableSet.copyOf(Iterables.transform(leg.getSources(), Publisher.FROM_KEY));
return new EquivalenceAssertionMessage(mid, ts, subj, adjacents, srcs);
}
use of org.atlasapi.messaging.v3.ContentEquivalenceAssertionMessage in project atlas-deer by atlasapi.
the class ContentEquivalenceAssertionLegacyTransformer method toResourceRef.
protected Set<ResourceRef> toResourceRef(ContentEquivalenceAssertionMessage leg) {
if (leg.getAdjacent() == null || leg.getAdjacent().isEmpty()) {
return ImmutableSet.of();
}
DateTime madeUpUpdatedTime = new DateTime(leg.getTimestamp().millis(), UTC);
ImmutableSet.Builder<ResourceRef> resourceRefs = ImmutableSet.builder();
for (AdjacentRef adjacentRef : leg.getAdjacent()) {
resourceRefs.add(LegacyTransformer.toResourceRef(ID_CODEC.decode(adjacentRef.getId()).longValue(), Publisher.fromKey(adjacentRef.getSource()).requireValue(), adjacentRef.getType(), madeUpUpdatedTime));
}
return resourceRefs.build();
}
use of org.atlasapi.messaging.v3.ContentEquivalenceAssertionMessage in project atlas-deer by atlasapi.
the class ContentEquivalenceAssertionLegacyTransformerTest method testDeSerializesContentEquivalenceAssertionMessage.
@Test
public void testDeSerializesContentEquivalenceAssertionMessage() {
// given
ImmutableList<AdjacentRef> adjs = ImmutableList.of(new AdjacentRef("cf2", "item", Publisher.PA.key()));
Set<String> srcs = toKeys(Publisher.all());
ContentEquivalenceAssertionMessage msg = new ContentEquivalenceAssertionMessage("1", Timestamp.of(1L), "cyp", "item", "bbc.co.uk", adjs, srcs);
// when
EquivalenceAssertionMessage transformed = transformer.transform(msg);
// then
assertThat(transformed.getMessageId(), is(msg.getMessageId()));
assertThat(transformed.getTimestamp(), is(msg.getTimestamp()));
assertThat(transformed.getSubject().getId().longValue(), is(SubstitutionTableNumberCodec.lowerCaseOnly().decode(msg.getEntityId()).longValue()));
assertThat(transformed.getSubject().getSource().toString(), is(msg.getEntitySource()));
assertThat(transformed.getSubject().getResourceType(), is(ResourceType.CONTENT));
assertThat(toKeys(transformed.getPublishers()), is(msg.getSources()));
assertThat(Iterables.getOnlyElement(transformed.getAssertedAdjacents()).getId().longValue(), is(SubstitutionTableNumberCodec.lowerCaseOnly().decode(Iterables.getOnlyElement(adjs).getId()).longValue()));
assertThat(Iterables.getOnlyElement(transformed.getAssertedAdjacents()).getSource().key(), is(Iterables.getOnlyElement(adjs).getSource()));
assertThat(Iterables.getOnlyElement(transformed.getAssertedAdjacents()), instanceOf(ItemRef.class));
}
use of org.atlasapi.messaging.v3.ContentEquivalenceAssertionMessage in project atlas-persistence by atlasapi.
the class ContentEquivalenceAssertionMessageTest method prepareMessage.
private ContentEquivalenceAssertionMessage prepareMessage() {
Set<String> srcs = Sets.newHashSet(Publisher.BBC.key(), Publisher.ITV.key());
List<AdjacentRef> adjacent = Lists.newArrayList(new AdjacentRef("cyp", "episode", Publisher.PA.key()), new AdjacentRef("dms", "item", Publisher.ITV.key()));
return new ContentEquivalenceAssertionMessage("1", Timestamp.of(1), "cf2", "episode", "bbc.co.uk", adjacent, srcs);
}
use of org.atlasapi.messaging.v3.ContentEquivalenceAssertionMessage in project atlas-deer by atlasapi.
the class WorkersModule method createLegacyContentEquivalenceUpdatingWorker.
private Worker<ContentEquivalenceAssertionMessage> createLegacyContentEquivalenceUpdatingWorker(String workerName) {
ContentEquivalenceAssertionLegacyTransformer transformer = new ContentEquivalenceAssertionLegacyTransformer();
ContentEquivalenceUpdatingWorker worker = ContentEquivalenceUpdatingWorker.create(persistence.getContentEquivalenceGraphStore(), explicitEquivalenceMigrator(), WORKER_METRIC_PREFIX + workerName + ".", metricsModule.metrics(), createRateLimiter(contentEquivalenceGraphChangesMaxMessagesPerSecond));
return (ContentEquivalenceAssertionMessage message) -> worker.process(transformer.transform(message));
}
Aggregations