aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/test
diff options
context:
space:
mode:
authorUbuntu <sunshine.wang@huawei.com>2020-01-07 22:08:38 +0800
committerUbuntu <sunshine.wang@huawei.com>2020-01-07 22:15:15 +0800
commit8c02dcc9057a300c08a7fc22265c45c3c771226e (patch)
treeaf0bde6ae3429aa0e1103ae79bfbd7efb148173e /mso-catalog-db/src/test
parent8f37667d999101c2e4e395d810376173a5714794 (diff)
find workflow by pnf model uuid with CatalogDbClient
Issue-ID: SO-2558 Signed-off-by: Yaoguang Wang <sunshine.wang@huawei.com> Change-Id: I62d9ae70befdd870d217de64cca36fe04a69e96e
Diffstat (limited to 'mso-catalog-db/src/test')
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java34
1 files changed, 34 insertions, 0 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 b82c17dc84..d87ed517f4 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
@@ -20,23 +20,39 @@
package org.onap.so.db.catalog.client;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
+import java.util.List;
import javax.persistence.EntityNotFoundException;
import org.junit.Before;
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.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;
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(CatalogDbClient.class)
public class CatalogDbClientTest {
private CatalogDbClient catalogDbClient;
+ private CatalogDbClient mockedCatalogDbClient;
+
@Before
public void init() {
catalogDbClient = new CatalogDbClient();
+ mockedCatalogDbClient = PowerMockito.spy(catalogDbClient);
}
@Rule
@@ -171,4 +187,22 @@ public class CatalogDbClientTest {
assertTrue(aCvnfc.getModelCustomizationUUID().equals("a123"));
}
+ @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());
+ }
+
}