Search in sources :

Example 1 with NoSubscriptionException

use of org.zalando.nakadi.exceptions.runtime.NoSubscriptionException in project nakadi by zalando.

the class PostSubscriptionControllerTest method whenSubscriptionCreationIsDisabledThenCreationFails.

@Test
public void whenSubscriptionCreationIsDisabledThenCreationFails() throws Exception {
    final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase();
    when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSubscriptionException("", null));
    when(featureToggleService.isFeatureEnabled(DISABLE_SUBSCRIPTION_CREATION)).thenReturn(true);
    postSubscription(subscriptionBase).andExpect(status().isServiceUnavailable());
}
Also used : SubscriptionBase(org.zalando.nakadi.domain.SubscriptionBase) NoSubscriptionException(org.zalando.nakadi.exceptions.runtime.NoSubscriptionException) Test(org.junit.Test)

Example 2 with NoSubscriptionException

use of org.zalando.nakadi.exceptions.runtime.NoSubscriptionException in project nakadi by zalando.

the class PostSubscriptionControllerTest method whenMoreThanAllowedEventTypeThenUnprocessableEntity.

@Test
public void whenMoreThanAllowedEventTypeThenUnprocessableEntity() throws Exception {
    when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSubscriptionException("", null));
    when(subscriptionService.createSubscription(any())).thenThrow(new TooManyPartitionsException("msg"));
    final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase();
    final Problem expectedProblem = Problem.valueOf(UNPROCESSABLE_ENTITY, "msg");
    checkForProblem(postSubscription(subscriptionBase), expectedProblem);
}
Also used : SubscriptionBase(org.zalando.nakadi.domain.SubscriptionBase) TooManyPartitionsException(org.zalando.nakadi.exceptions.runtime.TooManyPartitionsException) NoSubscriptionException(org.zalando.nakadi.exceptions.runtime.NoSubscriptionException) Problem(org.zalando.problem.Problem) TestUtils.invalidProblem(org.zalando.nakadi.utils.TestUtils.invalidProblem) Test(org.junit.Test)

Example 3 with NoSubscriptionException

use of org.zalando.nakadi.exceptions.runtime.NoSubscriptionException in project nakadi by zalando.

the class PostSubscriptionControllerTest method whenEventTypeDoesNotExistThenUnprocessableEntity.

@Test
public void whenEventTypeDoesNotExistThenUnprocessableEntity() throws Exception {
    final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase();
    when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSubscriptionException("", null));
    when(subscriptionService.createSubscription(any())).thenThrow(new NoEventTypeException("msg"));
    final Problem expectedProblem = Problem.valueOf(UNPROCESSABLE_ENTITY, "msg");
    checkForProblem(postSubscription(subscriptionBase), expectedProblem);
}
Also used : SubscriptionBase(org.zalando.nakadi.domain.SubscriptionBase) NoSubscriptionException(org.zalando.nakadi.exceptions.runtime.NoSubscriptionException) Problem(org.zalando.problem.Problem) TestUtils.invalidProblem(org.zalando.nakadi.utils.TestUtils.invalidProblem) NoEventTypeException(org.zalando.nakadi.exceptions.runtime.NoEventTypeException) Test(org.junit.Test)

Example 4 with NoSubscriptionException

use of org.zalando.nakadi.exceptions.runtime.NoSubscriptionException in project nakadi by zalando.

the class PostSubscriptionControllerTest method whenPostValidSubscriptionThenOk.

@Test
public void whenPostValidSubscriptionThenOk() throws Exception {
    final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase();
    final Subscription subscription = new Subscription("123", new DateTime(DateTimeZone.UTC), subscriptionBase);
    when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSubscriptionException("", null));
    when(subscriptionService.createSubscription(any())).thenReturn(subscription);
    postSubscription(subscriptionBase).andExpect(status().isCreated()).andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON)).andExpect(content().string(sameJSONAs(TestUtils.JSON_TEST_HELPER.asJsonString(subscription)))).andExpect(header().string("Location", "/subscriptions/123")).andExpect(header().string("Content-Location", "/subscriptions/123"));
}
Also used : SubscriptionBase(org.zalando.nakadi.domain.SubscriptionBase) NoSubscriptionException(org.zalando.nakadi.exceptions.runtime.NoSubscriptionException) Subscription(org.zalando.nakadi.domain.Subscription) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 SubscriptionBase (org.zalando.nakadi.domain.SubscriptionBase)4 NoSubscriptionException (org.zalando.nakadi.exceptions.runtime.NoSubscriptionException)4 TestUtils.invalidProblem (org.zalando.nakadi.utils.TestUtils.invalidProblem)2 Problem (org.zalando.problem.Problem)2 DateTime (org.joda.time.DateTime)1 Subscription (org.zalando.nakadi.domain.Subscription)1 NoEventTypeException (org.zalando.nakadi.exceptions.runtime.NoEventTypeException)1 TooManyPartitionsException (org.zalando.nakadi.exceptions.runtime.TooManyPartitionsException)1