* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * 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 static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
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.im.StateManagement;
import org.onap.policy.drools.system.PolicyEngine;
+@RunWith(MockitoJUnitRunner.class)
public class PmStandbyStateChangeNotifierTest {
private static final String UNSUPPORTED_STATUS = "unsupported status";
private static final String PDP_ID = "my-pdp";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
Factory.setInstance(factory);
when(factory.makeTimer()).thenReturn(timer);
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * 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.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.kie.api.runtime.KieSession;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.utils.services.OrderedServiceImpl;
import org.onap.policy.distributed.locking.DistributedLockManager.DistributedLock;
import org.onap.policy.drools.core.PolicySession;
import org.onap.policy.drools.system.PolicyEngineConstants;
import org.powermock.reflect.Whitebox;
+@RunWith(MockitoJUnitRunner.class)
public class DistributedLockManagerTest {
private static final long EXPIRE_SEC = 900L;
private static final long RETRY_SEC = 60L;
*/
@Before
public void setUp() throws SQLException {
- MockitoAnnotations.initMocks(this);
-
// grant() and deny() calls will come through here and be immediately executed
session = new PolicySession(null, null, kieSess) {
@Override
List.of(opPolicy, op2Policy, unvalPolicy, valPolicy, artifactPolicy,
artifact2Policy, controller2Policy, controllerPolicy);
- assertEquals(expectedUndeployOrder, fsm.getUndeployablePoliciesAction(Collections.EMPTY_LIST));
- assertEquals(expectedUndeployOrder, fsm.getUndeployablePoliciesAction(Collections.EMPTY_LIST));
- assertEquals(expectedUndeployOrder, fsm.getUndeployablePoliciesAction(Collections.EMPTY_LIST));
+ assertEquals(expectedUndeployOrder, fsm.getUndeployablePoliciesAction(Collections.emptyList()));
+ assertEquals(expectedUndeployOrder, fsm.getUndeployablePoliciesAction(Collections.emptyList()));
+ assertEquals(expectedUndeployOrder, fsm.getUndeployablePoliciesAction(Collections.emptyList()));
}
@Test
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 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.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
+@RunWith(MockitoJUnitRunner.class)
public class DMaaPSimulatorJaxRsTest {
private static final String MESSAGE = "hello";
private static final String MESSAGE2 = "world";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
sim = new DMaaPSimulatorJaxRs();
}
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * 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 java.util.TreeMap;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.kie.api.KieBase;
import org.kie.api.definition.KiePackage;
import org.kie.api.definition.rule.Query;
import org.kie.api.runtime.rule.QueryResultsRow;
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.utils.services.OrderedServiceImpl;
import org.onap.policy.drools.core.PolicyContainer;
import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomGsonCoder;
import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration.PotentialCoderFilter;
+@RunWith(MockitoJUnitRunner.class)
public class MavenDroolsController2Test {
private static final int FACT1_OBJECT = 1000;
private static final int FACT3_OBJECT = 1001;
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
when(droolsProviders.getList()).thenReturn(Arrays.asList(prov1, prov2));
when(coderMgr.isDecodingSupported(GROUP, ARTIFACT, TOPIC)).thenReturn(true);
when(kieSess.getKieBase()).thenReturn(kieBase);
when(kieSess.getQueryResults(QUERY, PARM1, PARM2)).thenReturn(queryResults);
- when(kieSess.getFactHandle(FACT1_OBJECT)).thenReturn(fact1);
when(kieSess.getFactHandle(FACT3_OBJECT)).thenReturn(fact3);
when(kieSess.getObject(fact1)).thenReturn(FACT1_OBJECT);
when(kieSess.getObject(fact3)).thenReturn(FACT3_OBJECT);
when(kieSess.getObject(factex)).thenThrow(RUNTIME_EX);
- when(kieSess2.getFactHandles()).thenReturn(Collections.emptyList());
-
when(kieBase.getKiePackages()).thenReturn(Arrays.asList(pkg1, pkg2));
when(pkg1.getQueries()).thenReturn(Arrays.asList(query3));
assertFalse(drools.delete(SESSION1, "hello"));
// repeat, but generate exception while getting the first object
- when(kieSess.getObject(fact1)).thenThrow(RUNTIME_EX);
assertTrue(drools.delete(SESSION1, FACT3_OBJECT));
verify(kieSess, never()).delete(fact1);
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * 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.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.drools.core.DroolsRunnable;
import org.onap.policy.drools.core.PolicySession;
import org.onap.policy.drools.core.lock.LockCallback;
import org.onap.policy.drools.system.PolicyEngineConstants;
import org.powermock.reflect.Whitebox;
+@RunWith(MockitoJUnitRunner.class)
public class FeatureLockImplTest {
private static final String POLICY_ENGINE_EXECUTOR_FIELD = "executorService";
private static final String OWNER_KEY = "my key";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
Whitebox.setInternalState(PolicyEngineConstants.getManager(), POLICY_ENGINE_EXECUTOR_FIELD, exsvc);
}
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * 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.
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.openMocks(this);
doAnswer(args -> {
args.getArgument(0, Runnable.class).run();
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * 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.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.kie.api.runtime.KieSession;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.utils.time.CurrentTime;
import org.onap.policy.common.utils.time.TestTime;
import org.onap.policy.drools.core.PolicySession;
import org.onap.policy.drools.system.internal.SimpleLockManager.SimpleLock;
import org.powermock.reflect.Whitebox;
+@RunWith(MockitoJUnitRunner.class)
public class SimpleLockManagerTest {
private static final String POLICY_ENGINE_EXECUTOR_FIELD = "executorService";
private static final String TIME_FIELD = "currentTime";
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
// grant() and deny() calls will come through here and be immediately executed
session = new PolicySession(null, null, kieSess) {
@Override