summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java14
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java56
2 files changed, 60 insertions, 10 deletions
diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
index 0048a34d6c..0a5bdc51f3 100644
--- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
+++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java
@@ -1026,21 +1026,21 @@ public class CatalogDatabase implements Closeable {
*@author cb645j
*
*/
- public VfModuleCustomization getVfModuleCustomizationByModelName (String modelName) {
+ public VfModuleCustomization getVfModuleCustomizationByModelName(String modelName) {
- long startTime = System.currentTimeMillis ();
- LOGGER.debug ("Catalog database - get VfModuleCustomization By VfModule's ModelName: " + modelName);
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get VfModuleCustomization By VfModule's ModelName: " + modelName);
String hql = "SELECT VfModuleCustomization FROM VfModuleCustomization as vfmc LEFT OUTER JOIN VfModule as vfm on vfm.modelUUID = vfmc.vfModuleModelUuid where vfm.modelName = :model_name";
- Query query = getSession ().createQuery (hql);
- query.setParameter ("model_name", modelName);
+ Query query = getSession().createQuery(hql);
+ query.setParameter("model_name", modelName);
@SuppressWarnings("unchecked")
List<VfModuleCustomization> resultList = query.list();
// See if something came back. Name is unique, so
- if (resultList.isEmpty ()) {
- LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful query but Vf module NOT found", "CatalogDB", "getVfModuleCustomizationByModelName", null);
+ if (resultList.isEmpty()) {
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful query but Vf module NOT found", "CatalogDB", "getVfModuleCustomizationByModelName", null);
return null;
}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
index 9ea1ef8bd4..b32e705252 100644
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
+++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
@@ -1607,9 +1607,59 @@ public class CatalogDatabaseTest {
VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl");
}
- @Test(expected = Exception.class)
- public void ggetVfModuleCustomizationByModelNameTestException(){
- VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelName("tetes");
+
+ @Test
+ public void ggetVfModuleCustomizationByModelNameTest(){
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<VfModuleCustomization> list() throws Exception {
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+ vfModuleCustomization.setVfModuleModelUuid("123-uuid");
+ return Arrays.asList(vfModuleCustomization);
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VfModuleCustomization vfModuleCustomization = cd.getVfModuleCustomizationByModelName("tetes");
+ assertEquals("123-uuid", vfModuleCustomization.getVfModuleModelUuid());
+ }
+
+ @Test
+ public void ggetVfModuleCustomizationByModelNameEmptyTest(){
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ @Mock
+ public List<VfModuleCustomization> list() throws Exception {
+ return Arrays.asList();
+ }
+ };
+
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String hql) {
+ return mockUpQuery.getMockInstance();
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ VfModuleCustomization vfModuleCustomization = cd.getVfModuleCustomizationByModelName("tetes");
+ assertEquals(null, vfModuleCustomization);
}
@Test(expected = Exception.class)