/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications 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.TimeoutException;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.MockitoAnnotations;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType;
import org.onap.ccsdk.cds.controllerblueprints.common.api.Status;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
+@RunWith(MockitoJUnitRunner.class)
public class GrpcActorServiceManagerTest {
CdsActorServiceManager manager;
*/
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
future = new CompletableFuture<>();
manager = new CdsActorServiceManager(new OperationOutcome(), future);
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications 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 static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import org.junit.AfterClass;
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.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.ServiceInstance;
-import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
import org.onap.policy.cds.client.CdsProcessorGrpcClient;
import org.onap.policy.cds.properties.CdsServerProperties;
import org.onap.policy.simulators.CdsSimulator;
import org.onap.policy.simulators.Util;
+@RunWith(MockitoJUnitRunner.class)
public class GrpcOperationTest {
private static final String MY_VNF = "my-vnf";
private static final String MY_SVC_ID = "my-service-instance-id";
*/
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
// Setup the CDS properties
cdsProps = new CdsServerProperties();
cdsProps.setHost("10.10.10.10");
cdsProps.setPassword("testPassword");
cdsProps.setTimeout(1);
- // Setup cdsClient
- when(cdsClient.sendRequest(any(ExecutionServiceInput.class))).thenReturn(mock(CountDownLatch.class));
-
// Setup executor
executor = new PseudoExecutor();
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications 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.mockito.MockitoAnnotations;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.cds.properties.CdsServerProperties;
import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
+@RunWith(MockitoJUnitRunner.class)
public class GrpcOperatorTest {
GrpcOperator operation;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
operation = new GrpcOperator(CdsActorConstants.CDS_ACTOR, GrpcOperation.NAME, GrpcOperation::new);
CdsServerProperties props = new CdsServerProperties();
* ============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.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
+@RunWith(MockitoJUnitRunner.class)
public class DecisionOperatorTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-name";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
when(factory.get(CLIENT)).thenReturn(client);
oper = new MyOperator();
* ============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.Executor;
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.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
+@RunWith(MockitoJUnitRunner.class)
public class GuardConfigTest {
private static final String MY_CLIENT = "my-client";
private static final String PATH = "my-path";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
when(factory.get(MY_CLIENT)).thenReturn(client);
params = GuardParams.builder().onapName(ONAP_NAME).onapComponent(ONAP_COMP).onapInstance(ONAP_INST)
* ============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.
* Initializes mocks and sets up.
*/
public void setUpBasic() {
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.openMocks(this);
future = new CompletableFuture<>();
* ============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.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.simulators.TopicServer;
+@RunWith(MockitoJUnitRunner.class)
public class BasicBidirectionalTopicOperationTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-operation";
*/
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
oper = new MyOperation(ACTOR, OPERATION);
oper.setUpBasic();
}
* ============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.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler;
+@RunWith(MockitoJUnitRunner.class)
public class BidirectionalTopicActorTest {
private static final String ACTOR = "my-actor";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
actor = new MyActor();
actor.configure(Util.translateToMap(ACTOR, makeParams()));
}
import lombok.Setter;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
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.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler;
import org.onap.policy.controlloop.actorserviceprovider.topic.Forwarder;
+@RunWith(MockitoJUnitRunner.class)
public class BidirectionalTopicOperationTest {
private static final CommInfrastructure SINK_INFRA = CommInfrastructure.NOOP;
private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
*/
@Before
public void setUp() throws CoderException {
- MockitoAnnotations.initMocks(this);
-
when(config.getTopicHandler()).thenReturn(handler);
when(config.getForwarder()).thenReturn(forwarder);
when(config.getTimeoutMs()).thenReturn(TIMEOUT_MS);
* ============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.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams;
import org.onap.policy.controlloop.actorserviceprovider.topic.Forwarder;
import org.onap.policy.controlloop.actorserviceprovider.topic.SelectorKey;
+@RunWith(MockitoJUnitRunner.class)
public class BidirectionalTopicOperatorTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-operation";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
keys = List.of(new SelectorKey(""));
when(mgr.getTopicHandler(MY_SINK, MY_SOURCE)).thenReturn(handler);
* ============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.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams.TopicParamsBuilder;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
+@RunWith(MockitoJUnitRunner.class)
public class HttpOperationTest {
private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
rejectRequest = false;
nget = 0;
npost = 0;
* ============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.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
+@RunWith(MockitoJUnitRunner.class)
public class HttpOperatorTest {
private static final String ACTOR = "my-actor";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
when(factory.get(HTTP_CLIENT)).thenReturn(client);
oper = new MyOperator();
* ============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 javax.ws.rs.core.Response;
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.mockito.stubbing.Answer;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
/**
* Tests HttpOperation when polling is enabled.
*/
+@RunWith(MockitoJUnitRunner.class)
public class HttpPollingOperationTest {
private static final String BASE_URI = "http://my-host:6969/base-uri/";
private static final String MY_PATH = "my-path";
*/
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
when(client.getBaseUrl()).thenReturn(BASE_URI);
when(config.getClient()).thenReturn(client);
- when(config.getPath()).thenReturn(MY_PATH);
when(config.getMaxPolls()).thenReturn(MAX_POLLS);
when(config.getPollPath()).thenReturn(POLL_PATH);
when(config.getPollWaitSec()).thenReturn(POLL_WAIT_SEC);
// should throw an exception if we pass a plain HttpConfig
HttpConfig config2 = mock(HttpConfig.class);
- when(config2.getClient()).thenReturn(client);
- when(config2.getPath()).thenReturn(MY_PATH);
assertThatIllegalStateException().isThrownBy(() -> new MyOper(params, config2).setUsePolling());
}
* ============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.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
+@RunWith(MockitoJUnitRunner.class)
public class HttpPollingOperatorTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-name";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
when(factory.get(CLIENT)).thenReturn(client);
oper = new MyOperator();
* ============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 static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.when;
import ch.qos.logback.classic.Logger;
import java.time.Instant;
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.utils.NetLoggerUtil.EventType;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.slf4j.LoggerFactory;
+@RunWith(MockitoJUnitRunner.class)
public class OperationPartialTest {
private static final CommInfrastructure SINK_INFRA = CommInfrastructure.NOOP;
private static final CommInfrastructure SOURCE_INFRA = CommInfrastructure.UEB;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
executor = new PseudoExecutor();
params = ControlLoopOperationParams.builder().completeCallback(this::completer).requestId(REQ_ID)
.executor(executor).actorService(service).actor(ACTOR).operation(OPERATION).timeoutSec(TIMEOUT)
.startCallback(this::starter).build();
- when(service.getActor(OperationPartial.GUARD_ACTOR_NAME)).thenReturn(guardActor);
- when(guardActor.getOperator(OperationPartial.GUARD_OPERATION_NAME)).thenReturn(guardOperator);
- when(guardOperator.buildOperation(any())).thenReturn(guardOperation);
- when(guardOperation.start()).thenReturn(CompletableFuture.completedFuture(makeSuccess()));
-
config = new OperatorConfig(executor);
oper = new MyOper();
};
}
- private OperationOutcome makeSuccess() {
- OperationOutcome outcome = params.makeOutcome();
- outcome.setResult(OperationResult.SUCCESS);
-
- return outcome;
- }
-
/**
* Verifies a run.
*
* ============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.Executor;
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.actorserviceprovider.topic.BidirectionalTopicHandler;
import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicManager;
import org.onap.policy.controlloop.actorserviceprovider.topic.Forwarder;
import org.onap.policy.controlloop.actorserviceprovider.topic.SelectorKey;
+@RunWith(MockitoJUnitRunner.class)
public class BidirectionalTopicConfigTest {
private static final String MY_SINK = "my-sink";
private static final String MY_SOURCE = "my-source";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
List<SelectorKey> keys = Arrays.asList(new SelectorKey(""));
when(topicManager.getTopicHandler(MY_SINK, MY_SOURCE)).thenReturn(topicHandler);
* ============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.Function;
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.parameters.BeanValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.ActorService;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams.ControlLoopOperationParamsBuilder;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
+@RunWith(MockitoJUnitRunner.class)
public class ControlLoopOperationParamsTest {
private static final String NULL_MSG = "null";
private static final String EXPECTED_EXCEPTION = "expected exception";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
when(actorService.getActor(ACTOR)).thenReturn(actor);
when(actor.getOperator(OPERATION)).thenReturn(operator);
when(operator.buildOperation(any())).thenReturn(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.util.concurrent.Executor;
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.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
+@RunWith(MockitoJUnitRunner.class)
public class HttpConfigTest {
private static final String MY_CLIENT = "my-client";
private static final String MY_PATH = "my-path";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
when(factory.get(MY_CLIENT)).thenReturn(client);
HttpParams params = HttpParams.builder().clientName(MY_CLIENT).path(MY_PATH).timeoutSec(TIMEOUT_SEC).build();
* ============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.Executor;
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.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
+@RunWith(MockitoJUnitRunner.class)
public class HttpPollingConfigTest {
private static final String MY_CLIENT = "my-client";
private static final String MY_PATH = "my-path";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
when(factory.get(MY_CLIENT)).thenReturn(client);
params = HttpPollingParams.builder().maxPolls(MAX_POLLS).pollPath(POLL_PATH).pollWaitSec(WAIT_SEC)
* ============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.Future;
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;
+@RunWith(MockitoJUnitRunner.class)
public class FutureManagerTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
mgr = new FutureManager();
}
* ============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;
+@RunWith(MockitoJUnitRunner.class)
public class ListenerManagerTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
mgr = new ListenerManager();
}
* ============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.Function;
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;
+@RunWith(MockitoJUnitRunner.class)
public class PipelineControllerFutureTest {
private static final IllegalStateException EXPECTED_EXCEPTION = new IllegalStateException("expected exception");
private static final String TEXT = "some text";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
compFuture = spy(new CompletableFuture<>());
controller = new PipelineControllerFuture<>();
import java.util.Arrays;
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.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException;
+@RunWith(MockitoJUnitRunner.class)
public class BidirectionalTopicHandlerTest {
private static final String UNKNOWN = "unknown";
private static final String MY_SOURCE = "my-source";
*/
@Before
public void setUp() throws BidirectionalTopicClientException {
- MockitoAnnotations.initMocks(this);
-
when(mgr.getTopicSinks(MY_SINK)).thenReturn(Arrays.asList(publisher));
when(mgr.getTopicSources(Arrays.asList(MY_SOURCE))).thenReturn(Arrays.asList(subscriber));
* ============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.BiConsumer;
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.actorserviceprovider.Util;
+@RunWith(MockitoJUnitRunner.class)
public class ForwarderTest {
private static final String TEXT = "some text";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
forwarder = new Forwarder(Arrays.asList(new SelectorKey(KEY1), new SelectorKey(KEY2, SUBKEY)));
forwarder.register(Arrays.asList(VALUEA_REQID, VALUEA_SUBREQID), listener1);
verify(listener1b, times(2)).accept(any(), any());
verify(listener2).accept(any(), any());
verify(listener3).accept(any(), any());
-
- // listener throws an exception
- doThrow(new IllegalStateException("expected exception")).when(listener1).accept(any(), any());
}
/*
* ============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.BiConsumer;
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.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.StandardCoderObject;
+@RunWith(MockitoJUnitRunner.class)
public class TopicListenerImplTest {
private static final StandardCoder coder = new StandardCoder();
private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
topic = new TopicListenerImpl();
forwarder1 = topic.addForwarder(new SelectorKey(KEY1));
* ============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.ArgumentCaptor;
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.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.utils.resources.ResourceUtils;
+@RunWith(MockitoJUnitRunner.class)
public class AppcLcmTopicServerTest {
private static final String MY_TOPIC = "my-topic";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
server = new AppcLcmTopicServer(sink, source);
}
* ============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.ArgumentCaptor;
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.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.utils.resources.ResourceUtils;
+@RunWith(MockitoJUnitRunner.class)
public class AppcLegacyTopicServerTest {
private static final String MY_TOPIC = "my-topic";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
server = new AppcLegacyTopicServer(sink, source);
}
* ============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.ArgumentCaptor;
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.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.utils.resources.ResourceUtils;
+@RunWith(MockitoJUnitRunner.class)
public class SdnrTopicServerTest {
private static final String MY_TOPIC = "my-topic";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
server = new SdnrTopicServer(sink, source);
}
* ============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.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.utils.coder.StandardCoder;
+@RunWith(MockitoJUnitRunner.class)
public class TopicServerTest {
private static final String MY_TOPIC = "my-topic";
private static final String TEXT = "hello";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
server = new MyServer();
}
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-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.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup;
+@RunWith(MockitoJUnitRunner.class)
public class DmaapSimProviderTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final long SWEEP_SEC = 10L;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
when(params.getTopicSweepSec()).thenReturn(SWEEP_SEC);
prov = new MyProvider(params);