Changes for Checkstyle 8.32
[policy/models.git] / models-interactions / model-actors / actorServiceProvider / src / test / java / org / onap / policy / controlloop / actorserviceprovider / impl / OperationPartialTest.java
index b73a3a0..e2ed2d9 100644 (file)
@@ -140,7 +140,7 @@ public class OperationPartialTest {
      */
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
-        /**
+        /*
          * Attach appender to the logger.
          */
         appender.setContext(logger.getLoggerContext());
@@ -324,13 +324,7 @@ public class OperationPartialTest {
         Map<String, Object> payload = params.getPayload();
         assertNotNull(payload);
 
-        @SuppressWarnings("unchecked")
-        Map<String, Object> resource = (Map<String, Object>) payload.get("resource");
-        assertNotNull(resource);
-
-        @SuppressWarnings("unchecked")
-        Map<String, Object> guard = (Map<String, Object>) resource.get("guard");
-        assertEquals(oper.makeGuardPayload(), guard);
+        assertEquals(oper.makeGuardPayload(), payload);
     }
 
     @Test
@@ -341,13 +335,13 @@ public class OperationPartialTest {
         // request id changes, so remove it
         payload.remove("requestId");
 
-        assertEquals("{actor=my-actor, recipe=my-operation, target=my-entity}", payload.toString());
+        assertEquals("{actor=my-actor, operation=my-operation, target=my-entity}", payload.toString());
 
         // repeat, but with closed loop name
         event.setClosedLoopControlName("my-loop");
         payload = oper.makeGuardPayload();
         payload.remove("requestId");
-        assertEquals("{actor=my-actor, recipe=my-operation, target=my-entity, clname=my-loop}", payload.toString());
+        assertEquals("{actor=my-actor, operation=my-operation, target=my-entity, clname=my-loop}", payload.toString());
     }
 
     @Test
@@ -537,7 +531,7 @@ public class OperationPartialTest {
             }
         };
 
-        verifyRun("testSetRetryFlag_testRetryOnFailure_NullOutcome", 1, 1, PolicyResult.FAILURE, null, noop());
+        verifyRun("testSetRetryFlag_testRetryOnFailure_NullOutcome", 1, 1, PolicyResult.FAILURE, noop());
     }
 
     @Test
@@ -1033,6 +1027,10 @@ public class OperationPartialTest {
         assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage());
         assertEquals(PolicyResult.SUCCESS, outcome.getResult());
 
+        oper.setOutcome(outcome, PolicyResult.SUCCESS);
+        assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage());
+        assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+
         for (PolicyResult result : FAILURE_RESULTS) {
             outcome = new OperationOutcome();
             oper.setOutcome(outcome, result);
@@ -1185,10 +1183,7 @@ public class OperationPartialTest {
     private void verifyRun(String testName, int expectedCallbacks, int expectedOperations,
                     PolicyResult expectedResult) {
 
-        String expectedSubRequestId =
-                        (expectedResult == PolicyResult.FAILURE_EXCEPTION ? null : String.valueOf(expectedOperations));
-
-        verifyRun(testName, expectedCallbacks, expectedOperations, expectedResult, expectedSubRequestId, noop());
+        verifyRun(testName, expectedCallbacks, expectedOperations, expectedResult, noop());
     }
 
     /**
@@ -1198,13 +1193,12 @@ public class OperationPartialTest {
      * @param expectedCallbacks number of callbacks expected
      * @param expectedOperations number of operation invocations expected
      * @param expectedResult expected outcome
-     * @param expectedSubRequestId expected sub request ID
      * @param manipulator function to modify the future returned by
      *        {@link OperationPartial#start(ControlLoopOperationParams)} before the tasks
      *        in the executor are run
      */
     private void verifyRun(String testName, int expectedCallbacks, int expectedOperations, PolicyResult expectedResult,
-                    String expectedSubRequestId, Consumer<CompletableFuture<OperationOutcome>> manipulator) {
+                    Consumer<CompletableFuture<OperationOutcome>> manipulator) {
 
         tstart = null;
         opstart = null;
@@ -1250,7 +1244,9 @@ public class OperationPartialTest {
             }
 
             if (expectedOperations > 0) {
-                assertEquals(testName, expectedSubRequestId, opend.getSubRequestId());
+                assertNotNull(testName, oper.getSubRequestId());
+                assertEquals(testName + " op start", oper.getSubRequestId(), opstart.getSubRequestId());
+                assertEquals(testName + " op end", oper.getSubRequestId(), opend.getSubRequestId());
             }
         }
 
@@ -1263,7 +1259,7 @@ public class OperationPartialTest {
     private void setOperCoderException() {
         oper = new MyOper() {
             @Override
-            protected Coder makeCoder() {
+            protected Coder getCoder() {
                 return new StandardCoder() {
                     @Override
                     public String encode(Object object, boolean pretty) throws CoderException {