X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=inline;f=rapp-manager-models%2Fsrc%2Ftest%2Fjava%2Fcom%2Foransc%2Frappmanager%2Fmodels%2FRappServiceEnablerTest.java;h=4c0a63c1871a98d914d745e27d9b21730aae73ae;hb=HEAD;hp=69ddc9bc30f20ce162fa002918ffa8fafc191f05;hpb=509ba7b8570f02caefb8212a2254302ba33e5add;p=nonrtric%2Fplt%2Frappmanager.git diff --git a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/RappServiceEnablerTest.java b/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/RappServiceEnablerTest.java deleted file mode 100755 index 69ddc9b..0000000 --- a/rapp-manager-models/src/test/java/com/oransc/rappmanager/models/RappServiceEnablerTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * ============LICENSE_START====================================================================== - * Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved. - * =============================================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END======================================================================== - */ - -package com.oransc.rappmanager.models; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.oransc.rappmanager.models.csar.RappCsarConfigurationHandler; -import com.oransc.rappmanager.models.rapp.Rapp; -import com.oransc.rappmanager.models.rapp.RappResources; -import com.oransc.rappmanager.models.rappinstance.RappACMInstance; -import com.oransc.rappmanager.models.rappinstance.RappDMEInstance; -import com.oransc.rappmanager.models.rappinstance.RappInstance; -import com.oransc.rappmanager.models.rappinstance.RappSMEInstance; -import java.util.Set; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ContextConfiguration; - -@SpringBootTest -@ContextConfiguration(classes = {ObjectMapper.class, RappCsarConfigurationHandler.class}) -class RappServiceEnablerTest { - - @Autowired - RappCsarConfigurationHandler rappCsarConfigurationHandler; - String validCsarFileLocation = "src/test/resources/"; - private final String validRappFile = "valid-rapp-package.csar"; - - @Test - void testRappIsDmeAndSmeEnabled() { - RappResources rappResources = rappCsarConfigurationHandler.getRappResource( - Rapp.builder().name("").packageName(validRappFile).packageLocation(validCsarFileLocation).build()); - Rapp rapp = Rapp.builder().name("").rappResources(rappResources).packageName(validRappFile) - .packageLocation(validCsarFileLocation).build(); - assertTrue(rapp.isDMEEnabled()); - assertTrue(rapp.isSMEEnabled()); - } - - @Test - void testRappIsNotDmeEnabled() { - RappResources rappResources = rappCsarConfigurationHandler.getRappResource( - Rapp.builder().name("").packageName(validRappFile).packageLocation(validCsarFileLocation).build()); - Rapp rapp = Rapp.builder().name("").rappResources(rappResources).packageName(validRappFile) - .packageLocation(validCsarFileLocation).build(); - rapp.getRappResources().setDme(null); - assertFalse(rapp.isDMEEnabled()); - } - - @Test - void testRappIsNotSmeEnabled() { - RappResources rappResources = rappCsarConfigurationHandler.getRappResource( - Rapp.builder().name("").packageName(validRappFile).packageLocation(validCsarFileLocation).build()); - Rapp rapp = Rapp.builder().name("").rappResources(rappResources).packageName(validRappFile) - .packageLocation(validCsarFileLocation).build(); - rapp.getRappResources().setSme(null); - assertFalse(rapp.isSMEEnabled()); - } - - @Test - void testRappIsNotDmeEnabledWithFolder() { - RappResources rappResources = rappCsarConfigurationHandler.getRappResource( - Rapp.builder().name("").packageName(validRappFile).packageLocation(validCsarFileLocation).build()); - Rapp rapp = Rapp.builder().name("").rappResources(rappResources).packageName(validRappFile) - .packageLocation(validCsarFileLocation).build(); - rapp.getRappResources().getDme().setConsumerInfoTypes(Set.of()); - rapp.getRappResources().getDme().setProducerInfoTypes(Set.of()); - rapp.getRappResources().getDme().setInfoConsumers(Set.of()); - rapp.getRappResources().getDme().setInfoProducers(Set.of()); - assertFalse(rapp.isDMEEnabled()); - } - - @Test - void testRappIsNotSmeEnabledWithFolder() { - RappResources rappResources = rappCsarConfigurationHandler.getRappResource( - Rapp.builder().name("").packageName(validRappFile).packageLocation(validCsarFileLocation).build()); - Rapp rapp = Rapp.builder().name("").rappResources(rappResources).packageName(validRappFile) - .packageLocation(validCsarFileLocation).build(); - rapp.getRappResources().getSme().setProviderFunctions(Set.of()); - rapp.getRappResources().getSme().setServiceApis(Set.of()); - rapp.getRappResources().getSme().setInvokers(Set.of()); - assertFalse(rapp.isSMEEnabled()); - } - - @Test - void testRappInstanceIsDmeAndSmeEnabled() { - RappInstance rappInstance = new RappInstance(); - rappInstance.setAcm(new RappACMInstance()); - RappDMEInstance rappDMEInstance = new RappDMEInstance(); - rappDMEInstance.setInfoTypesProducer(Set.of("prod1", "prod2")); - rappDMEInstance.setInfoTypeConsumer("cons"); - rappInstance.setDme(rappDMEInstance); - RappSMEInstance rappSMEInstance = new RappSMEInstance(); - rappSMEInstance.setProviderFunction("func1"); - rappInstance.setSme(rappSMEInstance); - assertTrue(rappInstance.isDMEEnabled()); - assertTrue(rappInstance.isSMEEnabled()); - } - - @Test - void testRappInstanceIsNotDmeEnabled() { - RappInstance rappInstance = new RappInstance(); - rappInstance.setAcm(new RappACMInstance()); - RappSMEInstance rappSMEInstance = new RappSMEInstance(); - rappSMEInstance.setProviderFunction("func1"); - rappInstance.setSme(rappSMEInstance); - assertFalse(rappInstance.isDMEEnabled()); - } - - @Test - void testRappInstanceIsNotSmeEnabled() { - RappInstance rappInstance = new RappInstance(); - rappInstance.setAcm(new RappACMInstance()); - RappDMEInstance rappDMEInstance = new RappDMEInstance(); - rappDMEInstance.setInfoTypesProducer(Set.of("prod1", "prod2")); - rappDMEInstance.setInfoTypeConsumer("cons"); - rappInstance.setDme(rappDMEInstance); - assertFalse(rappInstance.isSMEEnabled()); - } - - @Test - void testRappInstanceIsNotDmeEnabledWithoutContent() { - RappInstance rappInstance = new RappInstance(); - rappInstance.setAcm(new RappACMInstance()); - RappSMEInstance rappSMEInstance = new RappSMEInstance(); - rappSMEInstance.setProviderFunction("func1"); - rappInstance.setSme(rappSMEInstance); - RappDMEInstance rappDMEInstance = new RappDMEInstance(); - rappInstance.setDme(rappDMEInstance); - assertFalse(rappInstance.isDMEEnabled()); - } - - @Test - void testRappInstanceIsNotSmeEnabledWithoutContent() { - RappInstance rappInstance = new RappInstance(); - rappInstance.setAcm(new RappACMInstance()); - RappDMEInstance rappDMEInstance = new RappDMEInstance(); - rappDMEInstance.setInfoTypesProducer(Set.of("prod1", "prod2")); - rappDMEInstance.setInfoTypeConsumer("cons"); - rappInstance.setDme(rappDMEInstance); - RappSMEInstance rappSMEInstance = new RappSMEInstance(); - rappInstance.setSme(rappSMEInstance); - assertFalse(rappInstance.isSMEEnabled()); - } -}