2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.policy.controlloop;
 
  23 import static org.junit.Assert.assertEquals;
 
  24 import static org.junit.Assert.assertNotEquals;
 
  25 import static org.junit.Assert.assertNotNull;
 
  26 import static org.junit.Assert.assertTrue;
 
  28 import java.time.Instant;
 
  29 import org.junit.Test;
 
  31 public class ControlLoopOperationTest {
 
  35         ControlLoopOperation operation = new ControlLoopOperation();
 
  37         assertEquals(operation, operation);
 
  38         assertNotEquals(operation, new String());
 
  39         assertNotEquals(operation, null);
 
  41         assertTrue(operation.hashCode() != 0);
 
  42         assertTrue(operation.toString().startsWith("ControlLoopOperation"));
 
  44         assertNotNull(operation);
 
  46         operation.setActor("actor");
 
  47         assertEquals("actor", operation.getActor());
 
  49         operation.setOperation("operation");
 
  50         assertEquals("operation", operation.getOperation());
 
  52         Instant now = Instant.now();
 
  53         operation.setStart(now);
 
  54         assertEquals(now, operation.getStart());
 
  55         operation.setEnd(now);
 
  56         assertEquals(now, operation.getEnd());
 
  58         operation.setMessage("message");
 
  59         assertEquals("message", operation.getMessage());
 
  61         operation.setOutcome("outcome");
 
  62         assertEquals("outcome", operation.getOutcome());
 
  64         operation.setSubRequestId("1");
 
  65         assertEquals("1", operation.getSubRequestId());
 
  67         operation.setTarget("target");
 
  68         assertEquals("target", operation.getTarget());
 
  70         assertTrue(operation.hashCode() != 0);
 
  72         ControlLoopOperation operation2 = new ControlLoopOperation(operation);
 
  73         assertEquals(now, operation2.getEnd());
 
  75         assertEquals(operation, operation2);
 
  77         operation2.setActor("foo");
 
  78         assertNotEquals(operation, operation2);
 
  80         operation = new ControlLoopOperation(null);
 
  81         assertNotNull(operation.getStart());
 
  83         assertNotEquals(operation, operation2);
 
  85         assertTrue(operation.toMessage().startsWith("actor="));
 
  86         assertTrue(operation.toHistory().startsWith("actor="));