X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=rapp-manager-sme%2Fsrc%2Ftest%2Fjava%2Fcom%2Foransc%2Frappmanager%2Fsme%2Fservice%2FSmeDeployerTest.java;h=4574adaaa816db2bcab8c424db09cbaa845fd4eb;hb=f14562f10f7dd6ed770f2d1232add6b24eb85b91;hp=e00b2590e75bd5d97191fb0e83790f85f625b92b;hpb=77d91d4af1b3845fc8a3ef20cd6e54e9e6ff5a37;p=nonrtric%2Fplt%2Frappmanager.git diff --git a/rapp-manager-sme/src/test/java/com/oransc/rappmanager/sme/service/SmeDeployerTest.java b/rapp-manager-sme/src/test/java/com/oransc/rappmanager/sme/service/SmeDeployerTest.java index e00b259..4574ada 100755 --- a/rapp-manager-sme/src/test/java/com/oransc/rappmanager/sme/service/SmeDeployerTest.java +++ b/rapp-manager-sme/src/test/java/com/oransc/rappmanager/sme/service/SmeDeployerTest.java @@ -28,12 +28,12 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.oransc.rappmanager.models.rapp.Rapp; +import com.oransc.rappmanager.models.cache.RappCacheService; import com.oransc.rappmanager.models.csar.RappCsarConfigurationHandler; +import com.oransc.rappmanager.models.rapp.Rapp; +import com.oransc.rappmanager.models.rapp.RappState; import com.oransc.rappmanager.models.rappinstance.RappInstance; import com.oransc.rappmanager.models.rappinstance.RappSMEInstance; -import com.oransc.rappmanager.models.rapp.RappState; -import com.oransc.rappmanager.models.cache.RappCacheService; import com.oransc.rappmanager.models.statemachine.RappInstanceStateMachine; import com.oransc.rappmanager.models.statemachine.RappInstanceStateMachineConfig; import com.oransc.rappmanager.sme.configuration.SmeConfiguration; @@ -80,8 +80,6 @@ class SmeDeployerTest { @Autowired RappInstanceStateMachine rappInstanceStateMachine; @Autowired - RappCacheService rappCacheService; - @Autowired ObjectMapper objectMapper; private final String validRappFile = "valid-rapp-package.csar"; String URI_PROVIDER_REGISTRATIONS, URI_PROVIDER_REGISTRATION, URI_PUBLISH_APIS, URI_PUBLISH_API, URI_INVOKERS, @@ -245,7 +243,7 @@ class SmeDeployerTest { } @Test - void testCreateInvokerFailure() throws Exception { + void testCreateInvokerFailure() { UUID rappId = UUID.randomUUID(); Rapp rapp = Rapp.builder().rappId(rappId).name("").packageName(validRappFile).packageLocation(validCsarFileLocation) @@ -299,6 +297,18 @@ class SmeDeployerTest { assertTrue(deployRapp); } + @Test + void testDeployRappInstanceWithoutSme() throws Exception { + UUID rappId = UUID.randomUUID(); + Rapp rapp = + Rapp.builder().rappId(rappId).name("").packageName(validRappFile).packageLocation(validCsarFileLocation) + .state(RappState.PRIMED).build(); + RappInstance rappInstance = getRappInstance(); + rappInstance.setSme(null); + rappInstanceStateMachine.onboardRappInstance(rappInstance.getRappInstanceId()); + assertTrue(smeDeployer.deployRappInstance(rapp, rappInstance)); + } + @Test void testDeployRappFailure() throws Exception { UUID rappId = UUID.randomUUID(); @@ -365,7 +375,17 @@ class SmeDeployerTest { } @Test - void testUndeployRappInstanceFailure() throws Exception { + void testUndeployRappInstanceWithoutSme() { + UUID rappId = UUID.randomUUID(); + Rapp rapp = Rapp.builder().rappId(rappId).name(rappId.toString()).packageName(validRappFile) + .packageLocation(validCsarFileLocation).state(RappState.COMMISSIONED).build(); + RappInstance rappInstance = getRappInstance(); + rappInstance.setSme(null); + assertTrue(smeDeployer.undeployRappInstance(rapp, rappInstance)); + } + + @Test + void testUndeployRappInstanceFailure() { UUID rappId = UUID.randomUUID(); UUID apfId = UUID.randomUUID(); List invokers = List.of(String.valueOf(UUID.randomUUID()), String.valueOf(UUID.randomUUID())); @@ -393,11 +413,18 @@ class SmeDeployerTest { rappInstance.getSme().setProviderFunctionIds(providerFuncs.values().stream().toList()); rappInstance.getSme().setServiceApiIds(serviceApis); rappInstance.getSme().setInvokerIds(invokers); + rappInstanceStateMachine.onboardRappInstance(rappInstance.getRappInstanceId()); boolean undeployRapp = smeDeployer.undeployRappInstance(rapp, rappInstance); mockServer.verify(); assertFalse(undeployRapp); } + @Test + void testPrimingAndDeprimingDoesNothing() { + assertTrue(smeDeployer.primeRapp(null)); + assertTrue(smeDeployer.deprimeRapp(null)); + } + RappInstance getRappInstance() { RappSMEInstance rappSMEInstance = new RappSMEInstance(); rappSMEInstance.setInvokers("invoker-app1");