Loading src/test/java/org/etsi/osl/services/reposervices/ServiceSpecificationRepoServiceTest.java +33 −10 Original line number Diff line number Diff line Loading @@ -2,10 +2,12 @@ * @Author: Eduardo Santos * @Date: 2024-04-15 15:30:11 * @Last Modified by: Eduardo Santos * @Last Modified time: 2024-05-14 17:43:06 * @Last Modified time: 2024-05-24 21:02:02 */ package org.etsi.osl.services.reposervices; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.*; import static org.junit.Assert.*; Loading @@ -15,18 +17,11 @@ import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; import org.etsi.osl.model.ExperimentOnBoardDescriptor; import org.etsi.osl.model.Infrastructure; import org.etsi.osl.model.MANOprovider; import org.etsi.osl.model.NetworkServiceDescriptor; import org.etsi.osl.model.OnBoardingStatus; import org.etsi.osl.model.PackagingFormat; import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; import org.etsi.osl.tmf.scm633.api.ServiceSpecificationApiRouteBuilderNSD; Loading @@ -39,7 +34,6 @@ import org.junit.BeforeClass; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; Loading @@ -49,7 +43,6 @@ import org.springframework.test.context.junit4.SpringRunner; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.annotation.PostConstruct; import jakarta.validation.Valid; @RunWith(SpringRunner.class) Loading Loading @@ -101,6 +94,13 @@ public class ServiceSpecificationRepoServiceTest { when(resourceSpecRepoService.addResourceSpec(any())).thenReturn(resourceNSD); } /** * Tests that specFromNSDID returns a non-null result when retrieveNSD returns a non-null NetworkServiceDescriptor. * * This test verifies that the method retrieveNSD correctly returns a non-null NetworkServiceDescriptor * and that the specFromNSDID method does not return null in such a case. */ @Test public void testSpecFromNSDIDReturnsNonNullWhenRetrieveNSDReturnsNonNull() { // Setup Loading @@ -116,6 +116,11 @@ public class ServiceSpecificationRepoServiceTest { } /** * Tests that retrieveNSD returns null when the method is mocked to return null. * * This test verifies that the method retrieveNSD correctly returns null when it is expected to. */ @Test public void testRetrieveNSDReturnsNull() { // When retrieveNSD return null Loading @@ -129,6 +134,14 @@ public class ServiceSpecificationRepoServiceTest { assertNull(result); } /** * Tests the basic properties of the ServiceSpecification. * * This test verifies that the ServiceSpecification object created from the NSD ID * has the correct name, version, and description. It also checks that the correct number * of ServiceSpecification objects are created. */ @Test public void testServiceSpecificationBaseProperties() { String testId = "validId"; Loading @@ -148,6 +161,16 @@ public class ServiceSpecificationRepoServiceTest { assertEquals("tutorial_ns", serviceSpec.getDescription()); } /** * Tests the characteristics of the ServiceSpecification objects. * * This test verifies that the method specFromNSDID correctly creates a list of * ServiceSpecification objects from a given NSD ID and that these objects have the expected * characteristics. It checks that the list contains exactly one ServiceSpecification object and * that this object has the expected characteristics, including the correct name, value, and alias * for each characteristic. */ @Test public void testServiceSpecificationCharacteristics() { String testId = "validId"; Loading Loading
src/test/java/org/etsi/osl/services/reposervices/ServiceSpecificationRepoServiceTest.java +33 −10 Original line number Diff line number Diff line Loading @@ -2,10 +2,12 @@ * @Author: Eduardo Santos * @Date: 2024-04-15 15:30:11 * @Last Modified by: Eduardo Santos * @Last Modified time: 2024-05-14 17:43:06 * @Last Modified time: 2024-05-24 21:02:02 */ package org.etsi.osl.services.reposervices; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.*; import static org.junit.Assert.*; Loading @@ -15,18 +17,11 @@ import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; import org.etsi.osl.model.ExperimentOnBoardDescriptor; import org.etsi.osl.model.Infrastructure; import org.etsi.osl.model.MANOprovider; import org.etsi.osl.model.NetworkServiceDescriptor; import org.etsi.osl.model.OnBoardingStatus; import org.etsi.osl.model.PackagingFormat; import org.etsi.osl.tmf.OpenAPISpringBoot; import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; import org.etsi.osl.tmf.scm633.api.ServiceSpecificationApiRouteBuilderNSD; Loading @@ -39,7 +34,6 @@ import org.junit.BeforeClass; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; Loading @@ -49,7 +43,6 @@ import org.springframework.test.context.junit4.SpringRunner; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.annotation.PostConstruct; import jakarta.validation.Valid; @RunWith(SpringRunner.class) Loading Loading @@ -101,6 +94,13 @@ public class ServiceSpecificationRepoServiceTest { when(resourceSpecRepoService.addResourceSpec(any())).thenReturn(resourceNSD); } /** * Tests that specFromNSDID returns a non-null result when retrieveNSD returns a non-null NetworkServiceDescriptor. * * This test verifies that the method retrieveNSD correctly returns a non-null NetworkServiceDescriptor * and that the specFromNSDID method does not return null in such a case. */ @Test public void testSpecFromNSDIDReturnsNonNullWhenRetrieveNSDReturnsNonNull() { // Setup Loading @@ -116,6 +116,11 @@ public class ServiceSpecificationRepoServiceTest { } /** * Tests that retrieveNSD returns null when the method is mocked to return null. * * This test verifies that the method retrieveNSD correctly returns null when it is expected to. */ @Test public void testRetrieveNSDReturnsNull() { // When retrieveNSD return null Loading @@ -129,6 +134,14 @@ public class ServiceSpecificationRepoServiceTest { assertNull(result); } /** * Tests the basic properties of the ServiceSpecification. * * This test verifies that the ServiceSpecification object created from the NSD ID * has the correct name, version, and description. It also checks that the correct number * of ServiceSpecification objects are created. */ @Test public void testServiceSpecificationBaseProperties() { String testId = "validId"; Loading @@ -148,6 +161,16 @@ public class ServiceSpecificationRepoServiceTest { assertEquals("tutorial_ns", serviceSpec.getDescription()); } /** * Tests the characteristics of the ServiceSpecification objects. * * This test verifies that the method specFromNSDID correctly creates a list of * ServiceSpecification objects from a given NSD ID and that these objects have the expected * characteristics. It checks that the list contains exactly one ServiceSpecification object and * that this object has the expected characteristics, including the correct name, value, and alias * for each characteristic. */ @Test public void testServiceSpecificationCharacteristics() { String testId = "validId"; Loading