use of uk.gov.justice.subscription.domain.Location in project microservice_framework by CJSCommonPlatform.
the class RamlResourceToSubscriptionConverterTest method shouldConvertARamlResourceToASubscription.
@Test
public void shouldConvertARamlResourceToASubscription() throws Exception {
final String resourceUri = "resourceUri";
final String subscriptionName = "subscriptionName";
final String eventSourceName = "eventSourceName";
final String jmsUri = "jmsUri";
final Resource resource = mock(Resource.class, RETURNS_DEEP_STUBS.get());
final Event event_1 = mock(Event.class);
final Event event_2 = mock(Event.class);
final Collection<MimeType> mimeTypes = asList(mock(MimeType.class), mock(MimeType.class));
when(resource.getUri()).thenReturn(resourceUri);
when(subscriptionNamesGenerator.createSubscriptionNameFrom(resourceUri)).thenReturn(subscriptionName);
when(resource.getAction(POST).getBody().values()).thenReturn(mimeTypes);
when(ramlMimeTypeListToEventListConverter.toEvents(mimeTypes)).thenReturn(asList(event_1, event_2));
when(subscriptionNamesGenerator.createEventSourceNameFrom(resourceUri)).thenReturn(eventSourceName);
when(jmsUriGenerator.createJmsUriFrom(resourceUri)).thenReturn(jmsUri);
final Subscription subscription = ramlResourceToSubscriptionConverter.asSubscription(resource);
assertThat(subscription.getName(), is(subscriptionName));
final List<Event> events = subscription.getEvents();
assertThat(events.size(), is(2));
assertThat(events.get(0), is(event_1));
assertThat(events.get(1), is(event_2));
final Eventsource eventsource = subscription.getEventsource();
assertThat(eventsource.getName(), is(eventSourceName));
final Location location = eventsource.getLocation();
assertThat(location.getJmsUri(), is(jmsUri));
assertThat(location.getRestUri(), is(nullValue()));
}
use of uk.gov.justice.subscription.domain.Location in project microservice_framework by CJSCommonPlatform.
the class RamlResourceToSubscriptionConverter method asSubscription.
public Subscription asSubscription(final Resource resource) {
final String resourceUri = resource.getUri();
final String subscriptionName = subscriptionNamesGenerator.createSubscriptionNameFrom(resourceUri);
final Collection<MimeType> mimeTypes = resource.getAction(POST).getBody().values();
final List<Event> events = ramlMimeTypeListToEventListConverter.toEvents(mimeTypes);
final String eventSourceName = subscriptionNamesGenerator.createEventSourceNameFrom(resourceUri);
final String jmsUri = jmsUriGenerator.createJmsUriFrom(resourceUri);
final String restUri = null;
final Eventsource eventsource = new Eventsource(eventSourceName, new Location(jmsUri, restUri));
return new Subscription(subscriptionName, events, eventsource);
}
use of uk.gov.justice.subscription.domain.Location in project microservice_framework by CJSCommonPlatform.
the class EventsourceBuilderTest method shouldBuildAnEventsource.
@Test
public void shouldBuildAnEventsource() throws Exception {
final String name = "name";
final Location location = mock(Location.class);
final Eventsource eventsource = eventsource().withName(name).withLocation(location).build();
assertThat(eventsource.getName(), is(name));
assertThat(eventsource.getLocation(), is(location));
}
use of uk.gov.justice.subscription.domain.Location in project microservice_framework by CJSCommonPlatform.
the class SubscriptionDescriptorParserTest method assertPeopleEventSource.
private void assertPeopleEventSource(Eventsource eventsource) {
final String name = eventsource.getName();
assertThat(name, is("people"));
final Location location = eventsource.getLocation();
assertThat(location.getJmsUri(), is("jms:topic:people.event"));
assertThat(location.getRestUri(), is("http://localhost:8080/people/event-source-api/rest"));
}
use of uk.gov.justice.subscription.domain.Location in project microservice_framework by CJSCommonPlatform.
the class SubscriptionDescriptorParserTest method assertExampleEventSource.
private void assertExampleEventSource(Eventsource eventsource) {
final String name = eventsource.getName();
assertThat(name, is("examplecontext"));
final Location location = eventsource.getLocation();
assertThat(location.getJmsUri(), is("jms:topic:example.event"));
assertThat(location.getRestUri(), is("http://localhost:8080/example/event-source-api/rest"));
}
Aggregations