changes in test cases

Change-Id: Ibe8adafe0232afb117b10c7f3f289008c29db7df
diff --git a/capifcorejava/src/main/java/org/oransc/nonrtric/plt/capifcore/controller/DiscoverService.java b/capifcorejava/src/main/java/org/oransc/nonrtric/plt/capifcore/controller/DiscoverService.java
index b8dcbed..88b3f75 100644
--- a/capifcorejava/src/main/java/org/oransc/nonrtric/plt/capifcore/controller/DiscoverService.java
+++ b/capifcorejava/src/main/java/org/oransc/nonrtric/plt/capifcore/controller/DiscoverService.java
@@ -59,7 +59,7 @@
 

         DiscoveredAPIs discoveredApis = new DiscoveredAPIs();

         ServiceAPIDescription[] allApis = apiRegister.getAPIs();

-        ArrayList<ServiceAPIDescription> filteredApis = new ArrayList();

+        ArrayList<ServiceAPIDescription> filteredApis = new ArrayList<ServiceAPIDescription>();

         String gatewayDomain = "r1-expo-func-aef";

 

         for (ServiceAPIDescription serviceAPIDescription : allApis) {

diff --git a/capifcorejava/src/test/java/org/oransc/nonrtric/plt/capifcore/controller/DiscoverServiceTest.java b/capifcorejava/src/test/java/org/oransc/nonrtric/plt/capifcore/controller/DiscoverServiceTest.java
index 1f86869..cc7db76 100644
--- a/capifcorejava/src/test/java/org/oransc/nonrtric/plt/capifcore/controller/DiscoverServiceTest.java
+++ b/capifcorejava/src/test/java/org/oransc/nonrtric/plt/capifcore/controller/DiscoverServiceTest.java
@@ -23,15 +23,15 @@
 import static org.assertj.core.api.Assertions.assertThat;

 import static org.junit.jupiter.api.Assertions.assertThrows;

 import static org.junit.jupiter.api.Assertions.assertTrue;

-import static org.mockito.Mockito.mock;

 import static org.mockito.Mockito.when;

 

 import java.util.ArrayList;

 

-import org.junit.jupiter.api.BeforeEach;

 import org.junit.jupiter.api.DisplayName;

 import org.junit.jupiter.api.Test;

 import org.junit.jupiter.api.extension.ExtendWith;

+import org.mockito.Mock;

+import org.mockito.junit.jupiter.MockitoExtension;

 import org.oransc.capif.model.AefProfile;

 import org.oransc.capif.model.DiscoveredAPIs;

 import org.oransc.capif.model.ServiceAPIDescription;

@@ -42,33 +42,19 @@
 import org.springframework.web.server.ResponseStatusException;

 

 @ExtendWith(SpringExtension.class)

+@ExtendWith(MockitoExtension.class)

 class DiscoverServiceTest {

 

-    ApiRegister apiRegisterMock;

-    DiscoveredAPIs discoveredApisMock;

+

     DiscoverService testService;

-    AefProfile profileMock;

-    ServiceAPIDescription serviceAPIDescriptionMock;

-    ServiceAPIDescription serviceAPIDescription2Mock;

-    Version versionMock;

-

-    @BeforeEach

-    void initEach() {

-        apiRegisterMock = mock(ApiRegister.class);

-        testService = new DiscoverService(apiRegisterMock);

-        profileMock = mock(AefProfile.class);

-        serviceAPIDescriptionMock = mock(ServiceAPIDescription.class);

-        serviceAPIDescription2Mock = mock(ServiceAPIDescription.class);

-        versionMock = mock(Version.class);

-    }

-

 

     @Test

     @DisplayName("Get All the Service APIs")

-    void testGetAllServiceAPIs() {

-

+    void testGetAllServiceAPIs(@Mock ServiceAPIDescription serviceAPIDescriptionMock, @Mock ApiRegister apiRegisterMock,

+            @Mock AefProfile profileMock) {

+        testService = new DiscoverService(apiRegisterMock);

         ServiceAPIDescription[] resultApis = {serviceAPIDescriptionMock};

-        ArrayList<AefProfile> profile = new ArrayList();

+        ArrayList<AefProfile> profile = new ArrayList<AefProfile>();

         profile.add(profileMock);

         when(apiRegisterMock.getAPIs()).thenReturn(resultApis);

         when(serviceAPIDescriptionMock.getAefProfiles()).thenReturn(profile);

@@ -80,8 +66,8 @@
 

     @Test

     @DisplayName("Api Invoker Id Missing With Exception")

-    void testApiInvokerIdMissingShouldThrowException() {

-

+    void testApiInvokerIdMissingShouldThrowException(@Mock ApiRegister apiRegisterMock) {

+        testService = new DiscoverService(apiRegisterMock);

         ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> {

             testService.allServiceAPIsGet(" ", null, null, null, null, null, null, null, null, null);

         });

@@ -93,9 +79,11 @@
 

     @Test

     @DisplayName("Filter criteria based on the apiName, ApiVersion and AefProfile")

-    void testFilterCriteria() {

+    void testFilterCriteria(@Mock ServiceAPIDescription serviceAPIDescriptionMock, @Mock ApiRegister apiRegisterMock,

+            @Mock AefProfile profileMock, @Mock ServiceAPIDescription serviceAPIDescription2Mock,

+            @Mock Version versionMock) {

 

-

+        testService = new DiscoverService(apiRegisterMock);

         String apiName = "apiName";

         String apiName_wrong = "Wrong_name";

         String apiVersion = "apiVersion";

@@ -103,9 +91,9 @@
         when(serviceAPIDescriptionMock.getApiName()).thenReturn(apiName);

         when(serviceAPIDescription2Mock.getApiName()).thenReturn(apiName_wrong);

 

-        ArrayList<AefProfile> profile = new ArrayList();

+        ArrayList<AefProfile> profile = new ArrayList<AefProfile>();

         profile.add(profileMock);

-        ArrayList<Version> versionList = new ArrayList();

+        ArrayList<Version> versionList = new ArrayList<Version>();

         versionList.add(versionMock);

 

         ServiceAPIDescription[] resultApis = {serviceAPIDescriptionMock, serviceAPIDescription2Mock};