Search in sources :

Example 1 with Event

use of com.metabroadcast.columbus.telescope.api.Event in project atlas-deer by atlasapi.

the class ContentBootstrapWorkerTest method testReportingSuccessfulMigrationEvent.

@Test
public void testReportingSuccessfulMigrationEvent() throws RecoverableException, WriteException {
    ResourceUpdatedMessage updatedMessage = createUpdatedMessage();
    when(resourceRef.getId()).thenReturn(Id.valueOf(1));
    when(contentResolver.resolveIds(any(Collection.class))).thenReturn(Futures.immediateFuture(Resolved.valueOf(ImmutableList.of(content))));
    when(writer.writeContent(content)).thenReturn(successfulWriteResult);
    bootstrapWorker.process(updatedMessage);
    verify(telescopeClient, times(1)).createEvent(any(Event.class));
    verify(telescopeClient).createEvent(columbusTelescopeEventCaptor.capture());
    Event event = columbusTelescopeEventCaptor.getValue();
    assertThat(event.getStatus(), is(Event.Status.SUCCESS));
    assertThat(event.getType(), is(Event.Type.MIGRATION));
}
Also used : Collection(java.util.Collection) Event(com.metabroadcast.columbus.telescope.api.Event) ResourceUpdatedMessage(org.atlasapi.messaging.ResourceUpdatedMessage) Test(org.junit.Test)

Example 2 with Event

use of com.metabroadcast.columbus.telescope.api.Event in project atlas-deer by atlasapi.

the class ContentBootstrapWorkerTest method testReportingMigrationCorrectRawObjectIsSentAsPartOfTheEventReport.

@Test
public void testReportingMigrationCorrectRawObjectIsSentAsPartOfTheEventReport() throws RecoverableException, WriteException, JsonProcessingException {
    this.content.setLastFetched(DateTime.parse("2016-08-28T00:00:00Z"));
    ResourceUpdatedMessage updatedMessage = createUpdatedMessage();
    when(resourceRef.getId()).thenReturn(Id.valueOf(1));
    when(contentResolver.resolveIds(any(Collection.class))).thenReturn(Futures.immediateFuture(Resolved.valueOf(ImmutableList.of(content))));
    when(writer.writeContent(content)).thenReturn(successfulWriteResult);
    when(objectMapper.writeValueAsString(any(Content.class))).thenReturn(TEST_RAW_STRING);
    bootstrapWorker.process(updatedMessage);
    verify(telescopeClient, times(1)).createEvent(any(Event.class));
    verify(telescopeClient).createEvent(columbusTelescopeEventCaptor.capture());
    Event event = columbusTelescopeEventCaptor.getValue();
    assertThat(event.getEntityState().get().getRaw().get(), is(TEST_RAW_STRING));
    assertThat(event.getEntityState().get().getRawMime().get(), is(MimeType.APPLICATION_JSON.toString()));
    assertThat(event.getEntityState().get().getAtlasId().get(), is("c"));
}
Also used : Content(org.atlasapi.content.Content) Collection(java.util.Collection) Event(com.metabroadcast.columbus.telescope.api.Event) ResourceUpdatedMessage(org.atlasapi.messaging.ResourceUpdatedMessage) Test(org.junit.Test)

Example 3 with Event

use of com.metabroadcast.columbus.telescope.api.Event in project atlas-deer by atlasapi.

the class ColumbusTelescopeReporter method reportSuccessfulMigration.

public void reportSuccessfulMigration(Content content) {
    EntityState entityState = EntityState.builder().withAtlasId(codec.encode(content.getId().toBigInteger())).withRaw(getContentJsonString(content)).withRawMime(MimeType.APPLICATION_JSON.toString()).build();
    Event event = createEvent(entityState, Event.Status.SUCCESS);
    telescopeClient.createEvent(event);
}
Also used : Event(com.metabroadcast.columbus.telescope.api.Event) EntityState(com.metabroadcast.columbus.telescope.api.EntityState)

Aggregations

Event (com.metabroadcast.columbus.telescope.api.Event)3 Collection (java.util.Collection)2 ResourceUpdatedMessage (org.atlasapi.messaging.ResourceUpdatedMessage)2 Test (org.junit.Test)2 EntityState (com.metabroadcast.columbus.telescope.api.EntityState)1 Content (org.atlasapi.content.Content)1