Skip to content

Commit f64b478

Browse files
authored
Notify the customer about the upcoming license expiration
1 parent afe8eb5 commit f64b478

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/vo/Event.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import java.util.Arrays;
44

55
public enum Event {
6-
CREATE_LICENSEE, CREATE_LICENSE;
6+
LICENSEE_CREATED,
7+
LICENSE_CREATED,
8+
WARNING_LEVEL_CHANGED;
79

810
public static Event parseString(final String value) {
911
return Arrays.stream(Event.values()).filter((e) -> e.name().equalsIgnoreCase(value)).findFirst().orElse(null);

NetLicensingClient/src/test/java/com/labs64/netlicensing/service/NotificationServiceTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void testCreate() throws Exception {
6565
newNotification.setActive(true);
6666

6767
final Set<Event> events = new HashSet<>();
68-
events.add(Event.CREATE_LICENSEE);
68+
events.add(Event.LICENSEE_CREATED);
6969

7070
newNotification.setEvents(events);
7171
newNotification.setProtocol(NotificationProtocol.WEBHOOK);
@@ -89,7 +89,7 @@ public void testCreate() throws Exception {
8989
@Test
9090
public void testNameIsRequired() throws Exception {
9191
final Notification newNotification = new NotificationImpl();
92-
newNotification.addEvent(Event.CREATE_LICENSEE);
92+
newNotification.addEvent(Event.LICENSEE_CREATED);
9393
newNotification.setProtocol(NotificationProtocol.WEBHOOK);
9494
newNotification.addProperty(Constants.Notification.ENDPOINT, "http://www.test.test");
9595

@@ -118,7 +118,7 @@ public void testEventsIsRequired() throws Exception {
118118
public void testTypeIsRequired() throws Exception {
119119
final Notification newNotification = new NotificationImpl();
120120
newNotification.setName("Notification 1");
121-
newNotification.addEvent(Event.CREATE_LICENSEE);
121+
newNotification.addEvent(Event.LICENSEE_CREATED);
122122
newNotification.addProperty(Constants.Notification.ENDPOINT, "http://www.test.test");
123123
newNotification.setPayload("${event}");
124124

@@ -133,7 +133,7 @@ public void testTypeIsRequired() throws Exception {
133133
public void testEndpointIsRequired() throws Exception {
134134
final Notification newNotification = new NotificationImpl();
135135
newNotification.setName("Notification 1");
136-
newNotification.addEvent(Event.CREATE_LICENSEE);
136+
newNotification.addEvent(Event.LICENSEE_CREATED);
137137
newNotification.setProtocol(NotificationProtocol.WEBHOOK);
138138

139139
final Exception e = assertThrows(ServiceException.class, () -> {
@@ -151,8 +151,9 @@ public void testGet() throws Exception {
151151
assertEquals("Notification 14", notification.getName());
152152

153153
final Set<Event> expectedEvents = new HashSet<>();
154-
expectedEvents.add(Event.CREATE_LICENSEE);
155-
expectedEvents.add(Event.CREATE_LICENSE);
154+
expectedEvents.add(Event.LICENSEE_CREATED);
155+
expectedEvents.add(Event.LICENSE_CREATED);
156+
expectedEvents.add(Event.WARNING_LEVEL_CHANGED);
156157

157158
assertEquals(expectedEvents, notification.getEvents());
158159
assertEquals(NotificationProtocol.WEBHOOK, notification.getProtocol());
@@ -170,7 +171,7 @@ public void testList() throws Exception {
170171
assertEquals(3, notifications.getItemsNumber());
171172
assertEquals("N001-TEST", notifications.getContent().get(0).getNumber());
172173
assertEquals("Notification 2", notifications.getContent().get(1).getName());
173-
assertEquals(Event.CREATE_LICENSEE.name(), notifications.getContent().get(2).getEvents().stream().map(Enum::name).collect(Collectors.joining(",")));
174+
assertEquals(Event.LICENSEE_CREATED.name(), notifications.getContent().get(2).getEvents().stream().map(Enum::name).collect(Collectors.joining(",")));
174175
}
175176

176177
@Test
@@ -181,7 +182,7 @@ public void testUpdate() throws Exception {
181182
notification.addProperty(NOTIFICATION_CUSTOM_PROPERTY, "Test Value");
182183

183184
final Set<Event> events = new HashSet<>();
184-
events.add(Event.CREATE_LICENSE);
185+
events.add(Event.LICENSE_CREATED);
185186

186187
notification.setEvents(events);
187188

@@ -191,7 +192,7 @@ public void testUpdate() throws Exception {
191192
assertEquals("Notification 2", updatedNotification.getName());
192193
assertEquals("N002-TEST", updatedNotification.getNumber());
193194
assertEquals(false, updatedNotification.getActive());
194-
assertEquals(Event.CREATE_LICENSE.name(), updatedNotification.getEvents().stream().map(Enum::name).collect(Collectors.joining(",")));
195+
assertEquals(Event.LICENSE_CREATED.name(), updatedNotification.getEvents().stream().map(Enum::name).collect(Collectors.joining(",")));
195196
}
196197

197198
@Test

NetLicensingClient/src/test/resources/mock/netlicensing-notification-get.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<property name="number">N014-TEST</property>
88
<property name="active">true</property>
99
<property name="name">Notification 14</property>
10-
<property name="events">CREATE_LICENSEE,CREATE_LICENSE</property>
10+
<property name="events">LICENSEE_CREATED,LICENSE_CREATED,WARNING_LEVEL_CHANGED</property>
1111
<property name="protocol">WEBHOOK</property>
1212
<property name="endpoint">http://www.test.test</property>
1313
<property name="payload">${event}</property>

NetLicensingClient/src/test/resources/mock/netlicensing-notification-list.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<property name="number">N001-TEST</property>
88
<property name="active">true</property>
99
<property name="name">Notification 1</property>
10-
<property name="events">CREATE_LICENSEE</property>
10+
<property name="events">LICENSEE_CREATED</property>
1111
<property name="protocol">WEBHOOK</property>
1212
<property name="endpoint">http://www.test1.test</property>
1313
<property name="payload">${event}</property>
@@ -16,7 +16,7 @@
1616
<property name="number">N002-TEST</property>
1717
<property name="active">true</property>
1818
<property name="name">Notification 2</property>
19-
<property name="events">CREATE_LICENSE</property>
19+
<property name="events">LICENSE_CREATED</property>
2020
<property name="protocol">WEBHOOK</property>
2121
<property name="endpoint">http://www.test2.test</property>
2222
<property name="payload">${event.timestamp}</property>
@@ -25,7 +25,7 @@
2525
<property name="number">N003-TEST</property>
2626
<property name="active">true</property>
2727
<property name="name">Notification 3</property>
28-
<property name="events">CREATE_LICENSEE</property>
28+
<property name="events">LICENSEE_CREATED</property>
2929
<property name="protocol">WEBHOOK</property>
3030
<property name="endpoint">http://www.test3.test</property>
3131
<property name="payload">${event.data}</property>

NetLicensingClient/src/test/resources/mock/netlicensing-notification-update.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<property name="number">N002-TEST</property>
88
<property name="active">false</property>
99
<property name="name">Notification 2</property>
10-
<property name="events">CREATE_LICENSEE</property>
10+
<property name="events">LICENSEE_CREATED</property>
1111
<property name="protocol">WEBHOOK</property>
1212
<property name="endpoint">http://www.test.test</property>
1313
<property name="payload">${event}</property>

0 commit comments

Comments
 (0)