use of org.zalando.nakadi.domain.SubscriptionBase in project nakadi by zalando.
the class PostSubscriptionControllerTest method whenCreateSubscriptionWithEmptyConsumerGroupThenUnprocessableEntity.
@Test
public void whenCreateSubscriptionWithEmptyConsumerGroupThenUnprocessableEntity() throws Exception {
final SubscriptionBase subscriptionBase = builder().withConsumerGroup("").buildSubscriptionBase();
final Problem expectedProblem = invalidProblem("consumer_group", "must contain at least one character");
checkForProblem(postSubscription(subscriptionBase), expectedProblem);
}
use of org.zalando.nakadi.domain.SubscriptionBase in project nakadi by zalando.
the class PostSubscriptionControllerTest method whenOwningApplicationIsNullThenUnprocessableEntity.
@Test
public void whenOwningApplicationIsNullThenUnprocessableEntity() throws Exception {
final SubscriptionBase subscriptionBase = builder().withOwningApplication(null).buildSubscriptionBase();
final Problem expectedProblem = invalidProblem("owning_application", "may not be null");
checkForProblem(postSubscription(subscriptionBase), expectedProblem);
}
use of org.zalando.nakadi.domain.SubscriptionBase in project nakadi by zalando.
the class PostSubscriptionControllerTest method whenSubscriptionExistsThenReturnIt.
@Test
public void whenSubscriptionExistsThenReturnIt() throws Exception {
final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase();
final Subscription existingSubscription = new Subscription("123", new DateTime(DateTimeZone.UTC), subscriptionBase);
when(subscriptionService.getExistingSubscription(any())).thenReturn(existingSubscription);
when(subscriptionService.createSubscription(any())).thenThrow(new NoEventTypeException("msg"));
postSubscription(subscriptionBase).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON)).andExpect(content().string(sameJSONAs(TestUtils.JSON_TEST_HELPER.asJsonString(existingSubscription)))).andExpect(header().string("Location", "/subscriptions/123")).andExpect(header().doesNotExist("Content-Location"));
}
use of org.zalando.nakadi.domain.SubscriptionBase in project nakadi by zalando.
the class RandomSubscriptionBuilder method buildSubscriptionBase.
public SubscriptionBase buildSubscriptionBase() {
final SubscriptionBase subscriptionBase = new SubscriptionBase();
subscriptionBase.setOwningApplication(owningApplication);
subscriptionBase.setEventTypes(eventTypes);
subscriptionBase.setConsumerGroup(consumerGroup);
subscriptionBase.setReadFrom(startFrom);
subscriptionBase.setInitialCursors(initialCursors);
return subscriptionBase;
}
use of org.zalando.nakadi.domain.SubscriptionBase in project nakadi by zalando.
the class SubscriptionServiceTest method whenSubscriptionCreatedThenKPIEventSubmitted.
@Test
public void whenSubscriptionCreatedThenKPIEventSubmitted() throws Exception {
final SubscriptionBase subscriptionBase = RandomSubscriptionBuilder.builder().buildSubscriptionBase();
final Subscription subscription = RandomSubscriptionBuilder.builder().withId("my_subscription_id1").build();
when(subscriptionRepository.createSubscription(subscriptionBase)).thenReturn(subscription);
subscriptionService.createSubscription(subscriptionBase);
checkKPIEventSubmitted(nakadiKpiPublisher, SUBSCRIPTION_LOG_ET, new JSONObject().put("subscription_id", "my_subscription_id1").put("status", "created"));
}
Aggregations