* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.eventmanager.StepContext;
+@RunWith(MockitoJUnitRunner.class)
public class GetTargetEntityOperation2Test {
private static final String GENERIC_VNF_ID = "generic-vnf.vnf-id";
private static final String VSERVER_NAME = "vserver.vserver-name";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
event = new VirtualControlLoopEvent();
event.setTarget("pnf.pnf-name");
event.setAai(Map.of("pnf.pnf-name", MY_PNF));
@Test
public void testSetProperty() {
- when(params.getTargetType()).thenReturn(TargetType.VM);
event.setTarget(GENERIC_VNF_NAME);
// not a property of interest - should be ignored
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.concurrent.CompletableFuture;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
-import org.onap.policy.controlloop.actorserviceprovider.TargetType;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.eventmanager.StepContext;
+@RunWith(MockitoJUnitRunner.class)
public class LockOperation2Test {
private static final String MY_PNF = "my-pnf";
private static final String MY_VNF = "my-vnf";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
event = new VirtualControlLoopEvent();
event.setTarget("pnf.pnf-name");
event.setAai(Map.of("pnf.pnf-name", MY_PNF));
when(stepContext.requestLock(anyString())).thenReturn(future);
- when(params.getTargetType()).thenReturn(TargetType.PNF);
when(params.getActor()).thenReturn(MY_ACTOR);
when(params.getOperation()).thenReturn(MY_OPERATION);
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Deque;
import java.util.List;
import java.util.Map;
import org.drools.core.WorkingMemory;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.kie.api.runtime.rule.FactHandle;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.sdnr.PciMessage;
import org.onap.policy.sdnr.PciResponse;
+@RunWith(MockitoJUnitRunner.class)
public class UsecasesEventManagerTest {
private static final UUID REQ_ID = UUID.randomUUID();
private static final String CL_NAME = "my-closed-loop-name";
*/
@Before
public void setUp() throws ControlLoopException, CoderException {
- MockitoAnnotations.initMocks(this);
-
- when(actors.getActor(SIMPLE_ACTOR)).thenReturn(policyActor);
- when(policyActor.getOperator(SIMPLE_OPERATION)).thenReturn(policyOperator);
- when(policyOperator.buildOperation(any())).thenReturn(policyOperation);
- when(policyOperation.getPropertyNames()).thenReturn(Collections.emptyList());
-
when(workMem.getFactHandle(any())).thenReturn(factHandle);
event = new VirtualControlLoopEvent();
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.concurrent.CompletableFuture;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actor.aai.AaiActor;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.onap.policy.controlloop.eventmanager.StepContext;
+@RunWith(MockitoJUnitRunner.class)
public class AaiCqStep2Test {
private static final UUID REQ_ID = UUID.randomUUID();
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
future = new CompletableFuture<>();
when(params.toBuilder()).thenReturn(ControlLoopOperationParams.builder().actorService(actors)
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.concurrent.CompletableFuture;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actor.aai.AaiActor;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.onap.policy.controlloop.eventmanager.StepContext;
+@RunWith(MockitoJUnitRunner.class)
public class AaiGetPnfStep2Test {
private static final String MY_TARGET = "my-target";
private static final UUID REQ_ID = UUID.randomUUID();
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
future = new CompletableFuture<>();
when(params.toBuilder()).thenReturn(ControlLoopOperationParams.builder().actorService(actors)
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.concurrent.CompletableFuture;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actor.aai.AaiActor;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.onap.policy.controlloop.eventmanager.StepContext;
+@RunWith(MockitoJUnitRunner.class)
public class AaiGetTenantStep2Test {
private static final String MY_VSERVER = "my-vserver";
private static final UUID REQ_ID = UUID.randomUUID();
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
future = new CompletableFuture<>();
when(params.toBuilder()).thenReturn(ControlLoopOperationParams.builder().actorService(actors)
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.drools.apps.controller.usecases.GetTargetEntityOperation2;
import org.onap.policy.drools.apps.controller.usecases.UsecasesConstants;
+@RunWith(MockitoJUnitRunner.class)
public class GetTargetEntityStep2Test {
@Mock
private ControlLoopOperationParams params;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
when(params.toBuilder()).thenReturn(ControlLoopOperationParams.builder());
master = new Step2(stepContext, params, event);
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.RelatedToProperty;
import org.onap.policy.controlloop.eventmanager.StepContext;
import org.onap.policy.drools.apps.controller.usecases.UsecasesConstants;
+@RunWith(MockitoJUnitRunner.class)
public class GuardStep2Test {
private static final String SOME_OTHER_VALUE = "some-other-value";
private static final String SOME_OTHER_KEY = "some-other-key";
private static final String MY_NAME = "my-name";
private static final String MY_TYPE = "my-type";
private static final String MY_CODE = "my-code";
- private static final String MY_SERVER = "my-server";
private static final String MY_SERVER2 = "my-server-2";
private static final String MY_SERVERNAME = "my-server-name";
private static final String MY_REGION = "my-region";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
aai.put("vserver.vserver-name", MY_SERVERNAME);
- when(event.getRequestId()).thenReturn(REQ_ID);
when(event.getAai()).thenReturn(aai);
- when(genericVnf.getVnfId()).thenReturn(MY_TARGET);
when(genericVnf.getVnfName()).thenReturn(MY_NAME);
when(genericVnf.getVnfType()).thenReturn(MY_TYPE);
when(genericVnf.getNfNamingCode()).thenReturn(MY_CODE);
when(customQuery.getGenericVnfByVnfId(MY_TARGET)).thenReturn(genericVnf);
- when(theVserver.getVserverId()).thenReturn(MY_SERVER);
- when(customQuery.getVserver()).thenReturn(theVserver);
-
when(cloudRegion.getCloudRegionId()).thenReturn(MY_REGION);
when(customQuery.getDefaultCloudRegion()).thenReturn(cloudRegion);
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.function.Consumer;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.eventmanager.ActorConstants;
import org.onap.policy.controlloop.eventmanager.StepContext;
+@RunWith(MockitoJUnitRunner.class)
public class LockStep2Test {
private static final String MY_TARGET = "my-target";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
future = new CompletableFuture<>();
when(stepContext.requestLock(MY_TARGET)).thenReturn(future);
import java.util.TreeMap;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.LinkedBlockingQueue;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.ModelVer;
import org.onap.policy.controlloop.eventmanager.StepContext;
import org.onap.policy.drools.apps.controller.usecases.UsecasesConstants;
+@RunWith(MockitoJUnitRunner.class)
public class Step2Test {
private static final UUID REQ_ID = UUID.randomUUID();
private static final String POLICY_ACTOR = "my-actor";
@Mock
private AaiCqResponse aaicq;
- private CompletableFuture<OperationOutcome> future;
private Map<String, String> payload;
private VirtualControlLoopEvent event;
private BlockingQueue<OperationOutcome> starts;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- future = new CompletableFuture<>();
-
// configure policy operation
when(actors.getActor(POLICY_ACTOR)).thenReturn(policyActor);
when(policyActor.getOperator(POLICY_OPERATION)).thenReturn(policyOperator);
when(policyOperator.buildOperation(any())).thenReturn(policyOperation);
- when(policyOperation.start()).thenReturn(future);
when(policyOperation.getPropertyNames()).thenReturn(List.of());
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.concurrent.ExecutorService;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+@RunWith(MockitoJUnitRunner.class)
public class ControlLoopEventManagerTest {
private static final UUID REQ_ID = UUID.randomUUID();
private static final String CL_NAME = "my-closed-loop-name";
*/
@Before
public void setUp() throws ControlLoopException, CoderException {
- MockitoAnnotations.initMocks(this);
-
params = new ControlLoopParams();
params.setClosedLoopControlName(CL_NAME);
params.setPolicyName(POLICY_NAME);
import java.util.function.Consumer;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
import org.onap.policy.drools.core.lock.Lock;
+@RunWith(MockitoJUnitRunner.class)
public class LockDataTest {
private static final String ENTITY = "my-entity";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
data = new LockData(ENTITY, REQ_ID);
}
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.concurrent.atomic.AtomicReference;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.ActorService;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.onap.policy.drools.domain.models.operational.OperationalTarget;
+@RunWith(MockitoJUnitRunner.class)
public class StepTest {
private static final UUID REQ_ID = UUID.randomUUID();
private static final String POLICY_ACTOR = "my-actor";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
future = new CompletableFuture<>();
// configure policy operation
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.ophistory.OperationHistoryDataManagerParams.OperationHistoryDataManagerParamsBuilder;
+@RunWith(MockitoJUnitRunner.class)
public class OperationHistoryDataManagerImplTest {
private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
event = new VirtualControlLoopEvent();
event.setClosedLoopControlName(MY_LOOP_NAME);
event.setRequestId(UUID.randomUUID());
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.appc.CommonHeader;
import org.onap.policy.appc.Request;
import org.onap.policy.appclcm.AppcLcmBody;
import org.onap.policy.sdnr.PciRequest;
import org.powermock.reflect.Whitebox;
+@RunWith(MockitoJUnitRunner.class)
public class BaseTestTest {
private static final String POLICY_NAME = "my-policy-name";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- when(policy.getIdentifier()).thenReturn(policyIdent);
- when(policyIdent.getName()).thenReturn(POLICY_NAME);
-
when(topics.createListener(eq(BaseTest.POLICY_CL_MGT_TOPIC), eq(VirtualControlLoopNotification.class),
any(StandardCoder.class))).thenReturn(policyClMgt);
when(topics.createListener(eq(BaseTest.APPC_LCM_READ_TOPIC), eq(AppcLcmDmaapWrapper.class),
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.appc.Request;
import org.onap.policy.appclcm.AppcLcmBody;
import org.onap.policy.appclcm.AppcLcmCommonHeader;
import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
import org.onap.policy.appclcm.AppcLcmInput;
import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.common.utils.coder.StandardCoderInstantAsMillis;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.sdnr.PciMessage;
import org.powermock.reflect.Whitebox;
+@RunWith(MockitoJUnitRunner.class)
public class DroolsRuleTestTest {
private static final String CONTROLLER_NAME = "my-controller-name";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- when(policy.getIdentifier()).thenReturn(policyIdent);
- when(policyIdent.getName()).thenReturn(POLICY_NAME);
-
- when(drools.factCount(CONTROLLER_NAME)).thenReturn(0L);
- when(controller.getDrools()).thenReturn(drools);
-
- when(rules.getControllerName()).thenReturn(CONTROLLER_NAME);
when(rules.getController()).thenReturn(controller);
- when(rules.setupPolicyFromFile(any())).thenAnswer(args -> {
- when(drools.factCount(CONTROLLER_NAME)).thenReturn(2L);
- return policy;
- });
+ when(rules.setupPolicyFromFile(any())).thenReturn(policy);
when(topics.createListener(DroolsRuleTest.POLICY_CL_MGT_TOPIC,
VirtualControlLoopNotification.class, controller)).thenReturn(policyClMgt);
when(topics.createListener(eq(DroolsRuleTest.APPC_LCM_READ_TOPIC), eq(AppcLcmDmaapWrapper.class),
any(StandardCoder.class))).thenReturn(appcLcmRead);
- when(topics.createListener(eq(DroolsRuleTest.APPC_CL_TOPIC), eq(Request.class),
- any(StandardCoderInstantAsMillis.class))).thenReturn(appcClSink);
- when(topics.createListener(eq(DroolsRuleTest.SDNR_CL_TOPIC), eq(PciMessage.class),
- any(StandardCoder.class))).thenReturn(sdnrClSink);
Function<String, Rules> ruleMaker = this::makeRules;
Supplier<HttpClients> httpClientMaker = this::makeHttpClients;
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
-import org.onap.policy.controlloop.common.rules.test.HttpClients;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
+@RunWith(MockitoJUnitRunner.class)
public class HttpClientsTest {
private static final String CLIENT_NAME = "MY-CLIENT";
@Test
public void test() throws HttpClientConfigException {
- MockitoAnnotations.initMocks(this);
-
HttpClientFactoryInstance.getClientFactory().destroy();
HttpClients clients = new HttpClients();
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSink;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
-import org.onap.policy.controlloop.common.rules.test.Listener;
-import org.onap.policy.controlloop.common.rules.test.TopicException;
+@RunWith(MockitoJUnitRunner.class)
public class ListenerTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String MY_TOPIC = "my-topic";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
when(mgr.getNoopTopicSink(MY_TOPIC)).thenReturn(sink);
listener = new Listener<>(MY_TOPIC, msg -> msg + MSG_SUFFIX) {
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.kie.api.definition.rule.Rule;
import org.kie.api.event.rule.AfterMatchFiredEvent;
import org.kie.api.event.rule.AgendaEventListener;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.Match;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.utils.test.log.logback.ExtractAppender;
import org.onap.policy.controlloop.ControlLoopEvent;
import org.onap.policy.controlloop.drl.legacy.ControlLoopParams;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.LoggerFactory;
+@RunWith(MockitoJUnitRunner.class)
public class RulesTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String CONTROLLER_NAME = "rulesTest";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
facts = new LinkedList<>();
ruleListeners = new LinkedList<>();
agendaListeners = new LinkedList<>();
return null;
}).when(kieSession).addEventListener(any(AgendaEventListener.class));
- doAnswer(args -> {
- agendaListeners.remove(args.getArgument(0));
- return null;
- }).when(kieSession).removeEventListener(any(AgendaEventListener.class));
-
rules = new MyRules();
rules.configure(RESOURCE_DIR);
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.List;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.controlloop.common.rules.test.SimulatorException;
-import org.onap.policy.controlloop.common.rules.test.Simulators;
import org.onap.policy.controlloop.common.rules.test.Simulators.SimulatorBuilder;
+@RunWith(MockitoJUnitRunner.class)
public class SimulatorsTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
simulators = new Simulators();
}
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+@RunWith(MockitoJUnitRunner.class)
public class TopicsTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String MY_SOURCE_TOPIC = "my-source-topic";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
policy = new ToscaPolicy();
policy.setName(POLICY_NAME);
policy.setVersion("1.0.0");