Search in sources :

Example 1 with JsonConfig

use of org.zalando.nakadi.config.JsonConfig in project nakadi by zalando.

the class SubscriptionDbRepositoryTest method whenCreateSubscriptionThenOk.

@Test
public void whenCreateSubscriptionThenOk() throws Exception {
    final SubscriptionBase subscription = RandomSubscriptionBuilder.builder().build();
    final Subscription createdSubscription = repository.createSubscription(subscription);
    checkSubscriptionCreatedFromSubscriptionBase(createdSubscription, subscription);
    final int rows = template.queryForObject("SELECT count(*) FROM zn_data.subscription where s_id=?", Integer.class, createdSubscription.getId());
    assertThat("Number of rows should be 1", rows, equalTo(1));
    final Map<String, Object> result = template.queryForMap("SELECT s_subscription_object FROM zn_data.subscription WHERE s_id=?", createdSubscription.getId());
    final ObjectMapper mapper = (new JsonConfig()).jacksonObjectMapper();
    final Subscription saved = mapper.readValue(result.get("s_subscription_object").toString(), Subscription.class);
    assertThat("Saved subscription equal to original one", saved, equalTo(createdSubscription));
}
Also used : SubscriptionBase(org.zalando.nakadi.domain.SubscriptionBase) JsonConfig(org.zalando.nakadi.config.JsonConfig) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Subscription(org.zalando.nakadi.domain.Subscription) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with JsonConfig

use of org.zalando.nakadi.config.JsonConfig in project nakadi by zalando.

the class Aruha771MigrationHelper method main.

public static void main(final String[] args) throws Exception {
    final Aruha771MigrationHelper helper = new Aruha771MigrationHelper(new HashGenerator(), new JsonConfig().jacksonObjectMapper());
    helper.fillSubscriptionsHashes();
}
Also used : JsonConfig(org.zalando.nakadi.config.JsonConfig) HashGenerator(org.zalando.nakadi.util.HashGenerator)

Aggregations

JsonConfig (org.zalando.nakadi.config.JsonConfig)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)1 Test (org.junit.Test)1 Subscription (org.zalando.nakadi.domain.Subscription)1 SubscriptionBase (org.zalando.nakadi.domain.SubscriptionBase)1 HashGenerator (org.zalando.nakadi.util.HashGenerator)1