Search in sources :

Example 16 with SubscriptionBase

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);
}
Also used : SubscriptionBase(org.zalando.nakadi.domain.SubscriptionBase) Problem(org.zalando.problem.Problem) TestUtils.invalidProblem(org.zalando.nakadi.utils.TestUtils.invalidProblem) Test(org.junit.Test)

Example 17 with SubscriptionBase

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);
}
Also used : SubscriptionBase(org.zalando.nakadi.domain.SubscriptionBase) Problem(org.zalando.problem.Problem) TestUtils.invalidProblem(org.zalando.nakadi.utils.TestUtils.invalidProblem) Test(org.junit.Test)

Example 18 with SubscriptionBase

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"));
}
Also used : SubscriptionBase(org.zalando.nakadi.domain.SubscriptionBase) Subscription(org.zalando.nakadi.domain.Subscription) NoEventTypeException(org.zalando.nakadi.exceptions.runtime.NoEventTypeException) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 19 with SubscriptionBase

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;
}
Also used : SubscriptionBase(org.zalando.nakadi.domain.SubscriptionBase)

Example 20 with 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"));
}
Also used : SubscriptionBase(org.zalando.nakadi.domain.SubscriptionBase) JSONObject(org.json.JSONObject) Subscription(org.zalando.nakadi.domain.Subscription) Test(org.junit.Test)

Aggregations

SubscriptionBase (org.zalando.nakadi.domain.SubscriptionBase)24 Test (org.junit.Test)19 Subscription (org.zalando.nakadi.domain.Subscription)7 TestUtils.invalidProblem (org.zalando.nakadi.utils.TestUtils.invalidProblem)6 Problem (org.zalando.problem.Problem)6 Before (org.junit.Before)4 EventType (org.zalando.nakadi.domain.EventType)4 NoSubscriptionException (org.zalando.nakadi.exceptions.runtime.NoSubscriptionException)4 DateTime (org.joda.time.DateTime)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JsonConfig (org.zalando.nakadi.config.JsonConfig)2 NoEventTypeException (org.zalando.nakadi.exceptions.runtime.NoEventTypeException)2 SubscriptionCursorWithoutToken (org.zalando.nakadi.view.SubscriptionCursorWithoutToken)2 NakadiTestUtils.createSubscription (org.zalando.nakadi.webservice.utils.NakadiTestUtils.createSubscription)2 TestStreamingClient (org.zalando.nakadi.webservice.utils.TestStreamingClient)2 Charsets (com.google.common.base.Charsets)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Resources (com.google.common.io.Resources)1 RestAssured (com.jayway.restassured.RestAssured)1