Clean up NotificationMessage
[netconf.git] / netconf / mdsal-netconf-notification / src / test / java / org / opendaylight / netconf / mdsal / notification / impl / NotificationsTransformUtilTest.java
index efbbb54f032bf192d4115a94a96b1e51100f31c1..9056ac2c4ac3366bed9de8d2a4536db5a7d4b529 100644 (file)
@@ -12,7 +12,7 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.withSettings;
 
-import java.util.Date;
+import java.time.Instant;
 import java.util.Set;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -32,7 +32,7 @@ import org.xmlunit.diff.DefaultNodeMatcher;
 import org.xmlunit.diff.ElementSelectors;
 
 public class NotificationsTransformUtilTest {
-    private static final Date DATE = new Date();
+    private static final Instant EVENT_TIME = Instant.now();
     private static final String INNER_NOTIFICATION = """
             <netconf-capability-change xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-notifications">
                 <deleted-capability>uri4</deleted-capability>
@@ -44,7 +44,7 @@ public class NotificationsTransformUtilTest {
     private static final String EXPECTED_NOTIFICATION =
         "<notification xmlns=\"urn:ietf:params:netconf:capability:notification:1.0\">\n"
         + INNER_NOTIFICATION
-        + "    <eventTime>" + NotificationMessage.RFC3339_DATE_FORMATTER.apply(DATE) + "</eventTime>\n"
+        + "    <eventTime>" + NotificationMessage.RFC3339_DATE_FORMATTER.apply(EVENT_TIME) + "</eventTime>\n"
         + "</notification>\n";
 
     private static NotificationsTransformUtil UTIL;
@@ -61,7 +61,7 @@ public class NotificationsTransformUtilTest {
             withSettings().extraInterfaces(EventInstantAware.class).defaultAnswer(Answers.CALLS_REAL_METHODS));
         doReturn(Set.of(new Uri("uri1"))).when(capabilityChange).getAddedCapability();
         doReturn(Set.of(new Uri("uri4"), new Uri("uri3"))).when(capabilityChange).getDeletedCapability();
-        doReturn(DATE.toInstant()).when((EventInstantAware) capabilityChange).eventInstant();
+        doReturn(EVENT_TIME).when((EventInstantAware) capabilityChange).eventInstant();
 
         final var notification = UTIL.transform(capabilityChange, Absolute.of(NetconfCapabilityChange.QNAME));
 
@@ -70,7 +70,7 @@ public class NotificationsTransformUtilTest {
 
     @Test
     public void testTransformFromDOM() throws Exception {
-        final var notification = new NotificationMessage(XmlUtil.readXmlToDocument(INNER_NOTIFICATION), DATE);
+        final var notification = new NotificationMessage(XmlUtil.readXmlToDocument(INNER_NOTIFICATION), EVENT_TIME);
 
         compareXml(EXPECTED_NOTIFICATION, notification.toString());
     }