diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestPublicBus.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestPublicBus.java
index 606d7dc..fc49f94 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestPublicBus.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestPublicBus.java
@@ -1,7 +1,7 @@
/*
* Copyright 2010-2013 Ning, Inc.
- * Copyright 2014 Groupon, Inc
- * Copyright 2014 The Billing Project, LLC
+ * Copyright 2014-2017 Groupon, Inc
+ * Copyright 2014-2017 The Billing Project, LLC
*
* The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
@@ -27,10 +27,8 @@ import org.joda.time.DateTime;
import org.killbill.billing.DBTestingHelper;
import org.killbill.billing.account.api.Account;
import org.killbill.billing.api.TestApiListener.NextEvent;
-import org.killbill.billing.beatrix.extbus.DefaultBusExternalEvent;
import org.killbill.billing.callcontext.DefaultCallContext;
import org.killbill.billing.catalog.api.BillingPeriod;
-import org.killbill.billing.catalog.api.PriceListSet;
import org.killbill.billing.catalog.api.ProductCategory;
import org.killbill.billing.entitlement.api.DefaultEntitlement;
import org.killbill.billing.notification.plugin.api.ExtBusEvent;
@@ -46,11 +44,6 @@ import org.killbill.billing.util.callcontext.CallContext;
import org.killbill.billing.util.callcontext.CallOrigin;
import org.killbill.billing.util.callcontext.UserType;
import org.killbill.billing.util.jackson.ObjectMapper;
-import org.killbill.billing.util.nodes.NodeCommand;
-import org.killbill.billing.util.nodes.NodeCommandMetadata;
-import org.killbill.billing.util.nodes.NodeCommandProperty;
-import org.killbill.billing.util.nodes.PluginNodeCommandMetadata;
-import org.killbill.billing.util.nodes.SystemNodeCommandType;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -58,65 +51,30 @@ import org.testng.annotations.Test;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.eventbus.Subscribe;
-import static org.awaitility.Awaitility.await;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.awaitility.Awaitility.await;
import static org.testng.Assert.assertNotNull;
public class TestPublicBus extends TestIntegrationBase {
- private PublicListener publicListener;
+ private static final ObjectMapper mapper = new ObjectMapper();
+ private PublicListener publicListener;
private AtomicInteger externalBusCount;
- private final ObjectMapper mapper = new ObjectMapper();
-
@Override
protected KillbillConfigSource getConfigSource() {
- ImmutableMap additionalProperties = new ImmutableMap.Builder()
- .put("org.killbill.billing.util.broadcast.rate", "500ms")
- .build();
+ final ImmutableMap<String, String> additionalProperties = new ImmutableMap.Builder<String, String>().put("org.killbill.billing.util.broadcast.rate", "500ms")
+ .build();
return getConfigSource("/beatrix.properties", additionalProperties);
}
-
- public class PublicListener {
-
- @Subscribe
- public void handleExternalEvents(final ExtBusEvent event) {
- log.info("GOT EXT EVENT " + event);
-
- if (event.getEventType() == ExtBusEventType.SUBSCRIPTION_CREATION ||
- event.getEventType() == ExtBusEventType.SUBSCRIPTION_CANCEL ||
- event.getEventType() == ExtBusEventType.SUBSCRIPTION_PHASE ||
- event.getEventType() == ExtBusEventType.SUBSCRIPTION_CHANGE ||
- event.getEventType() == ExtBusEventType.SUBSCRIPTION_UNCANCEL ||
- event.getEventType() == ExtBusEventType.SUBSCRIPTION_BCD_CHANGE) {
- try {
- final SubscriptionMetadata obj = (SubscriptionMetadata) mapper.readValue(event.getMetaData(), SubscriptionMetadata.class);
- Assert.assertNotNull(obj.getBundleExternalKey());
- Assert.assertNotNull(obj.getActionType());
- } catch (JsonParseException e) {
- Assert.fail("Could not deserialize metada section", e);
- } catch (JsonMappingException e) {
- Assert.fail("Could not deserialize metada section", e);
- } catch (IOException e) {
- Assert.fail("Could not deserialize metada section", e);
- }
- }
-
- externalBusCount.incrementAndGet();
-
- }
- }
-
@Override
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
-
/*
We copy the initialization instead of invoking the super method so we can add the registration
of the publicBus event;
@@ -162,7 +120,6 @@ public class TestPublicBus extends TestIntegrationBase {
@Test(groups = "slow")
public void testSimple() throws Exception {
-
final DateTime initialDate = new DateTime(2012, 2, 1, 0, 3, 42, 0, testTimeZone);
final int billingDay = 2;
@@ -189,7 +146,6 @@ public class TestPublicBus extends TestIntegrationBase {
addDaysAndCheckForCompletion(31, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_PAYMENT);
-
await().atMost(10, SECONDS).until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
@@ -197,12 +153,10 @@ public class TestPublicBus extends TestIntegrationBase {
return externalBusCount.get() == 10;
}
});
-
}
@Test(groups = "slow")
public void testTenantKVChange() throws Exception {
-
final TenantData tenantData = new DefaultTenant(null, clock.getUTCNow(), clock.getUTCNow(), "MY_TENANT", "key", "s3Cr3T");
final CallContext contextWithNoTenant = new DefaultCallContext(null, null, "loulou", CallOrigin.EXTERNAL, UserType.ADMIN, "no reason", "hum", UUID.randomUUID(), clock);
final Tenant tenant = tenantUserApi.createTenant(tenantData, contextWithNoTenant);
@@ -219,4 +173,34 @@ public class TestPublicBus extends TestIntegrationBase {
}
});
}
+
+ public class PublicListener {
+
+ @Subscribe
+ public void handleExternalEvents(final ExtBusEvent event) {
+ log.info("GOT EXT EVENT " + event);
+
+ if (event.getEventType() == ExtBusEventType.SUBSCRIPTION_CREATION ||
+ event.getEventType() == ExtBusEventType.SUBSCRIPTION_CANCEL ||
+ event.getEventType() == ExtBusEventType.SUBSCRIPTION_PHASE ||
+ event.getEventType() == ExtBusEventType.SUBSCRIPTION_CHANGE ||
+ event.getEventType() == ExtBusEventType.SUBSCRIPTION_UNCANCEL ||
+ event.getEventType() == ExtBusEventType.SUBSCRIPTION_BCD_CHANGE) {
+ try {
+ final SubscriptionMetadata obj = (SubscriptionMetadata) mapper.readValue(event.getMetaData(), SubscriptionMetadata.class);
+ Assert.assertNotNull(obj.getBundleExternalKey());
+ Assert.assertNotNull(obj.getActionType());
+ } catch (final JsonParseException e) {
+ Assert.fail("Could not deserialize metada section", e);
+ } catch (final JsonMappingException e) {
+ Assert.fail("Could not deserialize metada section", e);
+ } catch (final IOException e) {
+ Assert.fail("Could not deserialize metada section", e);
+ }
+ }
+
+ externalBusCount.incrementAndGet();
+
+ }
+ }
}