diff options
Diffstat (limited to 'mso-catalog-db/src/test/java')
-rw-r--r-- | mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index d87ed517f4..66fc0f5dc5 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -19,42 +19,33 @@ */ package org.onap.so.db.catalog.client; + import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verify; import java.util.ArrayList; import java.util.List; import javax.persistence.EntityNotFoundException; -import org.junit.Before; +import javax.ws.rs.core.UriBuilder; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.ArgumentMatchers; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; -import uk.co.blackpepper.bowman.Client; import org.onap.so.db.catalog.beans.Workflow; +import uk.co.blackpepper.bowman.Client; -@RunWith(PowerMockRunner.class) -@PrepareForTest(CatalogDbClient.class) +@RunWith(MockitoJUnitRunner.class) public class CatalogDbClientTest { + @Spy private CatalogDbClient catalogDbClient; - - private CatalogDbClient mockedCatalogDbClient; - - @Before - public void init() { - catalogDbClient = new CatalogDbClient(); - mockedCatalogDbClient = PowerMockito.spy(catalogDbClient); - } - @Rule public ExpectedException thrown = ExpectedException.none(); @@ -190,19 +181,13 @@ public class CatalogDbClientTest { @Test public final void testFindWorkflowByPnfModelUUID() throws Exception { String pnfResourceModelUUID = "f2d1f2b2-88bb-49da-b716-36ae420ccbff"; - Workflow wf = new Workflow(); - wf.setArtifactUUID("b2fd5627-55e4-4f4f-8064-9e6f443e9152"); - wf.setArtifactName("DummyPnfWorkflow"); - wf.setVersion(1.0); - List<Workflow> wfList = new ArrayList<Workflow>(); - wfList.add(wf); - - PowerMockito.doReturn(wfList).when(mockedCatalogDbClient, "getMultipleResources", - ArgumentMatchers.<Client<Workflow>>any(), ArgumentMatchers.anyObject()); - List<Workflow> results = mockedCatalogDbClient.findWorkflowByPnfModelUUID(pnfResourceModelUUID); - assertEquals(wf.getArtifactUUID(), results.get(0).getArtifactUUID()); - assertEquals(wf.getArtifactName(), results.get(0).getArtifactName()); - assertEquals(wf.getVersion(), results.get(0).getVersion()); + + doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any()); + List<Workflow> results = catalogDbClient.findWorkflowByPnfModelUUID(pnfResourceModelUUID); + verify(catalogDbClient).getMultipleResources(any(Client.class), + eq(UriBuilder.fromUri("/findWorkflowByPnfModelUUID") + .queryParam(CatalogDbClient.PNF_RESOURCE_MODEL_UUID, pnfResourceModelUUID).build())); + } } |