import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
import java.util.Map;
import org.mockito.MockitoAnnotations;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
-import org.onap.policy.controlloop.VirtualControlLoopEvent;
-import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
public class SoOperatorTest {
assertEquals(ACTOR + "." + OPERATION, oper.getFullName());
}
- @Test
- public void testMakeSoOperator() {
- oper = SoOperator.makeSoOperator(ACTOR, OPERATION, MyOperation::new);
-
- VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- ControlLoopEventContext context = new ControlLoopEventContext(event);
- ControlLoopOperationParams params =
- ControlLoopOperationParams.builder().actor(ACTOR).operation(OPERATION).context(context).build();
-
- Operation operation1 = oper.buildOperation(params);
- assertNotNull(operation1);
-
- Operation operation2 = oper.buildOperation(params);
- assertNotNull(operation2);
- assertNotSame(operation1, operation2);
- }
-
@Test
public void testDoConfigure_testGetters() {
- // should use given values
- assertSame(client, oper.getClient());
- assertEquals(PATH_GET, oper.getPathGet());
- assertEquals(MAX_GETS, oper.getMaxGets());
- assertEquals(WAIT_SEC_GETS, oper.getWaitSecGet());
-
- SoParams params = SoParams.builder().pathGet("unslashed").maxGets(MAX_GETS).waitSecGet(WAIT_SEC_GETS)
- .clientName(CLIENT).path(PATH).timeoutSec(TIMEOUT).build();
- Map<String, Object> paramMap = Util.translateToMap(OPERATION, params);
- oper.configure(paramMap);
- assertEquals("unslashed/", oper.getPathGet());
+ assertTrue(oper.getCurrentConfig() instanceof SoConfig);
// test invalid parameters
Map<String, Object> paramMap2 = Util.translateToMap(OPERATION, SoParams.builder().build());
private class MyOperator extends SoOperator {
public MyOperator() {
- super(ACTOR, OPERATION);
- }
-
- @Override
- public Operation buildOperation(ControlLoopOperationParams params) {
- return null;
+ super(ACTOR, OPERATION, null);
}
@Override
return factory;
}
}
-
- private class MyOperation extends SoOperation {
- public MyOperation(ControlLoopOperationParams params, SoOperator operator) {
- super(params, operator);
- }
- }
}