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;
}
@Test
- void testCreateInvokerFailure() throws Exception {
+ void testCreateInvokerFailure() {
UUID rappId = UUID.randomUUID();
Rapp rapp =
Rapp.builder().rappId(rappId).name("").packageName(validRappFile).packageLocation(validCsarFileLocation)
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();
assertTrue(undeployRapp);
}
+ @Test
+ 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();
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");