* ONAP PAP
* ================================================================================
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.pap.main.rest;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.Arrays;
+import jakarta.ws.rs.core.Response.Status;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
-import javax.ws.rs.core.Response.Status;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
private MyProvider prov;
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
Registry.newRegistry();
}
* @throws Exception if an error occurs
*/
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
prov = new MyProvider();
}
@Test
- public void testProviderBase() {
+ void testProviderBase() {
assertSame(lockit, ReflectionTestUtils.getField(prov, "updateLock"));
assertSame(reqmap, ReflectionTestUtils.getField(prov, "requestMap"));
}
@Test
- public void testProcess() throws Exception {
+ void testProcess() throws Exception {
prov.process(loadRequest(), this::handle);
assertGroup(getGroupUpdates(), GROUP1_NAME);
}
@Test
- public void testProcess_PfRtEx() throws Exception {
+ void testProcess_PfRtEx() throws Exception {
PfModelRuntimeException ex = new PfModelRuntimeException(Status.BAD_REQUEST, EXPECTED_EXCEPTION);
when(pdpGroupService.updatePdpGroups(any())).thenThrow(ex);
}
@Test
- public void testProcess_RuntimeEx() throws Exception {
+ void testProcess_RuntimeEx() throws Exception {
RuntimeException ex = new RuntimeException(EXPECTED_EXCEPTION);
when(pdpGroupService.updatePdpGroups(any())).thenThrow(ex);
}
@Test
- public void testProcessPolicy_NoGroups() throws Exception {
+ void testProcessPolicy_NoGroups() throws Exception {
when(pdpGroupService.getFilteredPdpGroups(any())).thenReturn(Collections.emptyList());
SessionData session =
}
@Test
- public void testGetPolicy() throws Exception {
+ void testGetPolicy() throws Exception {
PfModelException exc = new PfModelException(Status.CONFLICT, EXPECTED_EXCEPTION);
when(toscaService.getFilteredPolicyList(any())).thenThrow(exc);
}
@Test
- public void testGetPolicy_NotFound() throws Exception {
+ void testGetPolicy_NotFound() throws Exception {
when(toscaService.getFilteredPolicyList(any())).thenReturn(Collections.emptyList());
ToscaConceptIdentifierOptVersion req = loadRequest();
}
@Test
- public void testGetGroup() throws Exception {
+ void testGetGroup() throws Exception {
when(pdpGroupService.getFilteredPdpGroups(any())).thenReturn(loadGroups("getGroupDao.json"))
.thenReturn(loadGroups("groups.json"));
}
@Test
- public void testUpgradeGroup() throws Exception {
+ void testUpgradeGroup() throws Exception {
/*
* Each subgroup has a different PDP type and name.
*
}
@Test
- public void testUpgradeGroup_Multiple() throws Exception {
+ void testUpgradeGroup_Multiple() throws Exception {
/*
* Policy data in the DB: policy1=type1, policy2=type2, policy3=type3,
* policy4=type1
}
@Test
- public void testUpgradeGroup_NothingUpdated() throws Exception {
+ void testUpgradeGroup_NothingUpdated() throws Exception {
prov.clear();
prov.add(false);
private static class MyProvider extends ProviderBase {
/**
- * Used to determine whether or not to make an update when
- * {@link #makeUpdater(ToscaPolicy)} is called. The updater function removes an
+ * Used to determine whether to make an update when
+ * makeUpdater() is called. The updater function removes an
* item from this queue each time it is invoked.
*/
private final Queue<Boolean> shouldUpdate = new LinkedList<>();
}
public void add(Boolean... update) {
- shouldUpdate.addAll(Arrays.asList(update));
+ shouldUpdate.addAll(List.of(update));
}
@Override