Merge "Updated function test env with new tests and features"
[nonrtric.git] / policy-agent / src / test / java / org / oransc / policyagent / tasks / ServiceSupervisionTest.java
index 070e8da..495b2a5 100644 (file)
@@ -56,7 +56,7 @@ import org.oransc.policyagent.utils.LoggingUtils;
 import reactor.core.publisher.Mono;
 
 @ExtendWith(MockitoExtension.class)
-public class ServiceSupervisionTest {
+class ServiceSupervisionTest {
 
     private static final String SERVICE_NAME = "Service name";
     private static final String RIC_NAME = "name";
@@ -74,6 +74,7 @@ public class ServiceSupervisionTest {
         .name(RIC_NAME) //
         .baseUrl("baseUrl") //
         .managedElementIds(Collections.emptyList()) //
+        .controllerName("") //
         .build();
     private Ric ric = new Ric(ricConfig);
     private PolicyType policyType = ImmutablePolicyType.builder() //
@@ -87,10 +88,11 @@ public class ServiceSupervisionTest {
         .ric(ric) //
         .type(policyType) //
         .lastModified("lastModified") //
+        .isTransient(false) //
         .build();
 
     @Test
-    public void serviceExpired_policyAndServiceAreDeletedInRepoAndPolicyIsDeletedInRic() {
+    void serviceExpired_policyAndServiceAreDeletedInRepoAndPolicyIsDeletedInRic() {
         setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(2));
 
         setUpCreationOfA1Client();
@@ -111,7 +113,7 @@ public class ServiceSupervisionTest {
     }
 
     @Test
-    public void serviceExpiredButDeleteInRicFails_policyAndServiceAreDeletedInRepoAndErrorLoggedForRic() {
+    void serviceExpiredButDeleteInRicFails_policyAndServiceAreDeletedInRepoAndErrorLoggedForRic() {
         setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(2));
 
         setUpCreationOfA1Client();
@@ -131,13 +133,14 @@ public class ServiceSupervisionTest {
         assertThat(services.size()).isEqualTo(0);
 
         ILoggingEvent loggingEvent = logAppender.list.get(0);
-        assertThat(loggingEvent.getThrowableProxy().getMessage()).isEqualTo(originalErrorMessage);
-        String expectedLogMessage = "Could not delete policy: " + POLICY_ID + " from ric: " + RIC_NAME;
+        assertThat(loggingEvent.getLevel()).isEqualTo(WARN);
+        String expectedLogMessage =
+            "Could not delete policy: " + POLICY_ID + " from ric: " + RIC_NAME + ". Cause: " + originalErrorMessage;
         assertThat(loggingEvent.toString().contains(expectedLogMessage)).isTrue();
     }
 
     @Test
-    public void serviceNotExpired_shouldNotBeChecked() {
+    void serviceNotExpired_shouldNotBeChecked() {
         setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(2));
 
         ServiceSupervision serviceSupervisionUnderTest =
@@ -153,7 +156,7 @@ public class ServiceSupervisionTest {
     }
 
     @Test
-    public void serviceWithoutKeepAliveInterval_shouldNotBeChecked() {
+    void serviceWithoutKeepAliveInterval_shouldNotBeChecked() {
         setUpRepositoryWithKeepAliveInterval(Duration.ofSeconds(0));
 
         ServiceSupervision serviceSupervisionUnderTest =