diff options
author | 2018-12-20 11:16:31 -0500 | |
---|---|---|
committer | 2018-12-20 11:16:31 -0500 | |
commit | 8e8bfd22535e03f6c7df847813b5eaadd07c73ef (patch) | |
tree | 08c6d1cf4b3d897a15d7cff750647aee6a3b306a /ms/controllerblueprints/modules/service/src/test/java/org/onap | |
parent | 40d739b066bbc44b82e484ec204132c4652552b2 (diff) |
Add modelType service reactive compatible.
Change-Id: I0058a8136fe9ad62781f3d4556d2b95d11507f3f
Issue-ID: CCSDK-864
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/controllerblueprints/modules/service/src/test/java/org/onap')
3 files changed, 33 insertions, 39 deletions
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java index 8e258ab6d..e2bb4c5fa 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java @@ -25,9 +25,11 @@ import org.onap.ccsdk.apps.controllerblueprints.TestApplication; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; +import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler; import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.annotation.Commit; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Propagation; @@ -43,11 +45,12 @@ import java.util.List; public class ModelTypeServiceTest { private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class); @Autowired - ModelTypeService modelTypeService; + private ModelTypeHandler modelTypeHandler; String modelName = "test-datatype"; @Test + @Commit public void test01SaveModelType() throws Exception { log.info("**************** test01SaveModelType ********************"); @@ -62,18 +65,18 @@ public class ModelTypeServiceTest { modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); modelType.setUpdatedBy("xxxxxx@xxx.com"); - modelType = modelTypeService.saveModel(modelType); + modelType = modelTypeHandler.saveModel(modelType); log.info("Saved Mode {}", modelType.toString()); Assert.assertNotNull("Failed to get Saved ModelType", modelType); Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.getModelName()); - ModelType dbModelType = modelTypeService.getModelTypeByName(modelType.getModelName()); + ModelType dbModelType = modelTypeHandler.getModelTypeByName(modelType.getModelName()); Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")", dbModelType); // Model Update modelType.setUpdatedBy("bs2796@xxx.com"); - modelType = modelTypeService.saveModel(modelType); + modelType = modelTypeHandler.saveModel(modelType); Assert.assertNotNull("Failed to get Saved ModelType", modelType); Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.getUpdatedBy()); @@ -85,7 +88,7 @@ public class ModelTypeServiceTest { String tags = "test-datatype"; - List<ModelType> dbModelTypes = modelTypeService.searchModelTypes(tags); + List<ModelType> dbModelTypes = modelTypeHandler.searchModelTypes(tags); Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes); Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size() > 0); @@ -94,17 +97,17 @@ public class ModelTypeServiceTest { @Test public void test03GetModelType() throws Exception { log.info("************************* test03GetModelType *********************************"); - ModelType dbModelType = modelTypeService.getModelTypeByName(modelName); + ModelType dbModelType = modelTypeHandler.getModelTypeByName(modelName); Assert.assertNotNull("Failed to get response for api call getModelByName ", dbModelType); Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType.getModelName()); List<ModelType> dbDatatypeModelTypes = - modelTypeService.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); + modelTypeHandler.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes); Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size() > 0); List<ModelType> dbModelTypeByDerivedFroms = - modelTypeService.getModelTypeByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT); + modelTypeHandler.getModelTypeByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT); Assert.assertNotNull("Failed to find getModelTypeByDerivedFrom by tags", dbModelTypeByDerivedFroms); Assert.assertTrue("Failed to find getModelTypeByDerivedFrom by count", dbModelTypeByDerivedFroms.size() > 0); @@ -114,10 +117,10 @@ public class ModelTypeServiceTest { public void test04DeleteModelType() throws Exception { log.info( "************************ test03DeleteModelType ***********************"); - ModelType dbResourceMapping = modelTypeService.getModelTypeByName(modelName); + ModelType dbResourceMapping = modelTypeHandler.getModelTypeByName(modelName); Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping); Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping.getModelName()); - modelTypeService.deleteByModelName(dbResourceMapping.getModelName()); + modelTypeHandler.deleteByModelName(dbResourceMapping.getModelName()); } }
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java index c7147490d..d283377b3 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java @@ -17,48 +17,37 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-import org.apache.commons.io.FileUtils;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.junit.*;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.service.controller.ModelTypeController;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.annotation.Commit;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
-import java.io.File;
-import java.nio.charset.Charset;
import java.util.List;
@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+@DataJpaTest
@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ModelTypeRestTest {
private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class);
@Autowired
- ModelTypeRest modelTypeRest;
+ ModelTypeController modelTypeController;
String modelName = "test-datatype";
- @Before
- public void setUp() {
-
- }
-
-
- @After
- public void tearDown() {
- }
-
@Test
+ @Commit
public void test01SaveModelType() throws Exception {
log.info("**************** test01SaveModelType ********************");
@@ -73,18 +62,18 @@ public class ModelTypeRestTest { modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
+ BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
modelType.setUpdatedBy("xxxxxx@xxx.com");
- modelType = modelTypeRest.saveModelType(modelType);
+ modelType = modelTypeController.saveModelType(modelType);
log.info("Saved Mode {}", modelType.toString());
Assert.assertNotNull("Failed to get Saved ModelType", modelType);
Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.getModelName());
- ModelType dbModelType = modelTypeRest.getModelTypeByName(modelType.getModelName());
+ ModelType dbModelType = modelTypeController.getModelTypeByName(modelType.getModelName());
Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")",
dbModelType);
// Model Update
modelType.setUpdatedBy("bs2796@xxx.com");
- modelType = modelTypeRest.saveModelType(modelType);
+ modelType = modelTypeController.saveModelType(modelType);
Assert.assertNotNull("Failed to get Saved ModelType", modelType);
Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.getUpdatedBy());
@@ -96,7 +85,7 @@ public class ModelTypeRestTest { String tags = "test-datatype";
- List<ModelType> dbModelTypes = modelTypeRest.searchModelTypes(tags);
+ List<ModelType> dbModelTypes = modelTypeController.searchModelTypes(tags);
Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes);
Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size() > 0);
@@ -105,25 +94,26 @@ public class ModelTypeRestTest { @Test
public void test03GetModelType() throws Exception {
log.info("************************* test03GetModelType *********************************");
- ModelType dbModelType = modelTypeRest.getModelTypeByName(modelName);
- Assert.assertNotNull("Failed to get response for api call getModelByName ", dbModelType);
+ ModelType dbModelType = modelTypeController.getModelTypeByName(modelName);
+ Assert.assertNotNull("Failed to get response for api call getModelByName " + modelName, dbModelType);
Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType.getModelName());
List<ModelType> dbDatatypeModelTypes =
- modelTypeRest.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ modelTypeController.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes);
Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size() > 0);
}
@Test
+ @Commit
public void test04DeleteModelType() throws Exception {
log.info(
"************************ test03DeleteModelType ***********************");
- ModelType dbResourceMapping = modelTypeRest.getModelTypeByName(modelName);
+ ModelType dbResourceMapping = modelTypeController.getModelTypeByName(modelName);
Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping);
Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping.getModelName());
- modelTypeRest.deleteModelTypeByName(dbResourceMapping.getModelName());
+ modelTypeController.deleteModelTypeByName(dbResourceMapping.getModelName());
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java index 675d2c246..9c02d4cfe 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java @@ -29,6 +29,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant; import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.service.controller.ModelTypeController;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
import com.att.eelf.configuration.EELFLogger;
@@ -52,7 +53,7 @@ public class ServiceTemplateRestTest { private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateRestTest.class);
@Autowired
- ModelTypeRest modelTypeRest;
+ ModelTypeController modelTypeRest;
@Autowired
private ServiceTemplateRest serviceTemplateRest;
|