diff --git a/NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/vo/Event.java b/NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/vo/Event.java index 4b2304b1..3cd4ec16 100644 --- a/NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/vo/Event.java +++ b/NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/vo/Event.java @@ -3,7 +3,9 @@ import java.util.Arrays; public enum Event { - CREATE_LICENSEE, CREATE_LICENSE; + LICENSEE_CREATED, + LICENSE_CREATED, + WARNING_LEVEL_CHANGED; public static Event parseString(final String value) { return Arrays.stream(Event.values()).filter((e) -> e.name().equalsIgnoreCase(value)).findFirst().orElse(null); diff --git a/NetLicensingClient/src/test/java/com/labs64/netlicensing/service/NotificationServiceTest.java b/NetLicensingClient/src/test/java/com/labs64/netlicensing/service/NotificationServiceTest.java index 7a65030b..f4a09d2f 100644 --- a/NetLicensingClient/src/test/java/com/labs64/netlicensing/service/NotificationServiceTest.java +++ b/NetLicensingClient/src/test/java/com/labs64/netlicensing/service/NotificationServiceTest.java @@ -65,7 +65,7 @@ public void testCreate() throws Exception { newNotification.setActive(true); final Set events = new HashSet<>(); - events.add(Event.CREATE_LICENSEE); + events.add(Event.LICENSEE_CREATED); newNotification.setEvents(events); newNotification.setProtocol(NotificationProtocol.WEBHOOK); @@ -89,7 +89,7 @@ public void testCreate() throws Exception { @Test public void testNameIsRequired() throws Exception { final Notification newNotification = new NotificationImpl(); - newNotification.addEvent(Event.CREATE_LICENSEE); + newNotification.addEvent(Event.LICENSEE_CREATED); newNotification.setProtocol(NotificationProtocol.WEBHOOK); newNotification.addProperty(Constants.Notification.ENDPOINT, "http://www.test.test"); @@ -118,7 +118,7 @@ public void testEventsIsRequired() throws Exception { public void testTypeIsRequired() throws Exception { final Notification newNotification = new NotificationImpl(); newNotification.setName("Notification 1"); - newNotification.addEvent(Event.CREATE_LICENSEE); + newNotification.addEvent(Event.LICENSEE_CREATED); newNotification.addProperty(Constants.Notification.ENDPOINT, "http://www.test.test"); newNotification.setPayload("${event}"); @@ -133,7 +133,7 @@ public void testTypeIsRequired() throws Exception { public void testEndpointIsRequired() throws Exception { final Notification newNotification = new NotificationImpl(); newNotification.setName("Notification 1"); - newNotification.addEvent(Event.CREATE_LICENSEE); + newNotification.addEvent(Event.LICENSEE_CREATED); newNotification.setProtocol(NotificationProtocol.WEBHOOK); final Exception e = assertThrows(ServiceException.class, () -> { @@ -151,8 +151,9 @@ public void testGet() throws Exception { assertEquals("Notification 14", notification.getName()); final Set expectedEvents = new HashSet<>(); - expectedEvents.add(Event.CREATE_LICENSEE); - expectedEvents.add(Event.CREATE_LICENSE); + expectedEvents.add(Event.LICENSEE_CREATED); + expectedEvents.add(Event.LICENSE_CREATED); + expectedEvents.add(Event.WARNING_LEVEL_CHANGED); assertEquals(expectedEvents, notification.getEvents()); assertEquals(NotificationProtocol.WEBHOOK, notification.getProtocol()); @@ -170,7 +171,7 @@ public void testList() throws Exception { assertEquals(3, notifications.getItemsNumber()); assertEquals("N001-TEST", notifications.getContent().get(0).getNumber()); assertEquals("Notification 2", notifications.getContent().get(1).getName()); - assertEquals(Event.CREATE_LICENSEE.name(), notifications.getContent().get(2).getEvents().stream().map(Enum::name).collect(Collectors.joining(","))); + assertEquals(Event.LICENSEE_CREATED.name(), notifications.getContent().get(2).getEvents().stream().map(Enum::name).collect(Collectors.joining(","))); } @Test @@ -181,7 +182,7 @@ public void testUpdate() throws Exception { notification.addProperty(NOTIFICATION_CUSTOM_PROPERTY, "Test Value"); final Set events = new HashSet<>(); - events.add(Event.CREATE_LICENSE); + events.add(Event.LICENSE_CREATED); notification.setEvents(events); @@ -191,7 +192,7 @@ public void testUpdate() throws Exception { assertEquals("Notification 2", updatedNotification.getName()); assertEquals("N002-TEST", updatedNotification.getNumber()); assertEquals(false, updatedNotification.getActive()); - assertEquals(Event.CREATE_LICENSE.name(), updatedNotification.getEvents().stream().map(Enum::name).collect(Collectors.joining(","))); + assertEquals(Event.LICENSE_CREATED.name(), updatedNotification.getEvents().stream().map(Enum::name).collect(Collectors.joining(","))); } @Test diff --git a/NetLicensingClient/src/test/resources/mock/netlicensing-notification-get.xml b/NetLicensingClient/src/test/resources/mock/netlicensing-notification-get.xml index b58d21f9..ccd09372 100644 --- a/NetLicensingClient/src/test/resources/mock/netlicensing-notification-get.xml +++ b/NetLicensingClient/src/test/resources/mock/netlicensing-notification-get.xml @@ -7,7 +7,7 @@ N014-TEST true Notification 14 - CREATE_LICENSEE,CREATE_LICENSE + LICENSEE_CREATED,LICENSE_CREATED,WARNING_LEVEL_CHANGED WEBHOOK http://www.test.test ${event} diff --git a/NetLicensingClient/src/test/resources/mock/netlicensing-notification-list.xml b/NetLicensingClient/src/test/resources/mock/netlicensing-notification-list.xml index 223b4575..86959868 100644 --- a/NetLicensingClient/src/test/resources/mock/netlicensing-notification-list.xml +++ b/NetLicensingClient/src/test/resources/mock/netlicensing-notification-list.xml @@ -7,7 +7,7 @@ N001-TEST true Notification 1 - CREATE_LICENSEE + LICENSEE_CREATED WEBHOOK http://www.test1.test ${event} @@ -16,7 +16,7 @@ N002-TEST true Notification 2 - CREATE_LICENSE + LICENSE_CREATED WEBHOOK http://www.test2.test ${event.timestamp} @@ -25,7 +25,7 @@ N003-TEST true Notification 3 - CREATE_LICENSEE + LICENSEE_CREATED WEBHOOK http://www.test3.test ${event.data} diff --git a/NetLicensingClient/src/test/resources/mock/netlicensing-notification-update.xml b/NetLicensingClient/src/test/resources/mock/netlicensing-notification-update.xml index 92a06adf..09f59781 100644 --- a/NetLicensingClient/src/test/resources/mock/netlicensing-notification-update.xml +++ b/NetLicensingClient/src/test/resources/mock/netlicensing-notification-update.xml @@ -7,7 +7,7 @@ N002-TEST false Notification 2 - CREATE_LICENSEE + LICENSEE_CREATED WEBHOOK http://www.test.test ${event}