--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.onap.so.adapters.cnf.exceptions;\r
+\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.onap.so.adapters.cnf.model.*;\r
+import org.springframework.http.HttpStatus;\r
+import org.springframework.test.context.junit4.SpringRunner;\r
+\r
+import java.util.List;\r
+\r
+\r
+@RunWith(SpringRunner.class)\r
+public class ApplicationExceptionTest {\r
+\r
+ @Test\r
+ public void Test() throws Exception {\r
+\r
+ MulticloudInstanceRequest request = null;\r
+ List<PodStatus> podStatuses = null;\r
+ List<?> servicesStatuses = null;\r
+\r
+ String[] ipAddresses = new String[0];\r
+ \r
+ GroupVersionKind gVK = null;\r
+ \r
+ InstanceStatusResponse instanceStatusResponse=new InstanceStatusResponse("Err");\r
+\r
+ instanceStatusResponse.setPodStatuses(podStatuses);\r
+ instanceStatusResponse.setReady(true);\r
+ instanceStatusResponse.setRequest(request);\r
+ instanceStatusResponse.setResourceCount("s");\r
+ instanceStatusResponse.setServicesStatuses(servicesStatuses);\r
+\r
+ instanceStatusResponse.getPodStatuses();\r
+ instanceStatusResponse.getRequest();\r
+ instanceStatusResponse.getResourceCount();\r
+ instanceStatusResponse.getServicesStatuses();\r
+ instanceStatusResponse.isReady();\r
+\r
+ PodStatus podStatus = new PodStatus();\r
+\r
+ podStatus.setIpAddresses(ipAddresses);\r
+ podStatus.setName("name");\r
+ podStatus.setNameSpace("namespace");\r
+ podStatus.setReady(true);\r
+ podStatus.setStatus("ok");\r
+\r
+ podStatus.getIpAddresses();\r
+ podStatus.getName();\r
+ podStatus.getNameSpace();\r
+ podStatus.getStatus();\r
+ podStatus.isReady();\r
+\r
+ Resource resource = new Resource();\r
+ \r
+ resource.setGVK(gVK);\r
+ resource.setName("name");\r
+ \r
+ resource.getGVK();\r
+ resource.getName();\r
+\r
+ ApplicationException applicationexception=new ApplicationException(1,"Error");\r
+\r
+ applicationexception.setErrorCode(1);\r
+ applicationexception.setErrorMsg("Error");\r
+\r
+ applicationexception.getErrorCode();\r
+ applicationexception.getErrorMsg();\r
+ applicationexception.buildErrorResponse();\r
+\r
+ }\r
+}
\ No newline at end of file
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.multipart.MultipartFile;
-
-import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import static org.junit.Assert.assertEquals;
String rbName = "xyz";
String rbVersion = "v1";
String profileName = "p1";
+ MulticloudInstanceRequest request = null;
InstanceMiniResponse instanceMiniResponse = new InstanceMiniResponse(HttpStatus.OK.toString());
+
+ instanceMiniResponse.setId("a");
+ instanceMiniResponse.setNameSpace("ab");
+ instanceMiniResponse.setErrorMsg("Error");
+ instanceMiniResponse.setRequest(request);
+
+ instanceMiniResponse.getId();
+ instanceMiniResponse.getNameSpace();
+ instanceMiniResponse.getRequest();
+ instanceMiniResponse.getErrorMsg();
+
List<InstanceMiniResponse> instancList = new ArrayList<InstanceMiniResponse>();
instancList.add(instanceMiniResponse);
InstanceMiniResponseList instanceMiniRespList = new InstanceMiniResponseList(HttpStatus.OK.toString());
rb.setLabels(labels);
rb.setRbName("rb");
rb.setRbVersion("p1");
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
- cnfAdapterRest.createRB(rb);
-}
-catch(Exception e)
-{
-assert(true);
-}
+
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try {
+ cnfAdapterRest.createRB(rb);
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
String RbName = "rb";
String RbVersion = "p1";
-
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.getRB(RbName, RbVersion);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
String RbName = "rb";
String RbVersion = "p1";
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.deleteRB(RbName, RbVersion);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
String RbName = "rb";
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.getListOfRB(RbName);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
public void getListOfRBWithoutUsingRBNameTest() throws Exception {
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.getListOfRBWithoutUsingRBName();
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
MultipartFile file = Mockito.mock(MultipartFile.class);
Mockito.when(file.getOriginalFilename()).thenReturn("first value");
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
try {
cnfAdapterRest.uploadArtifactForRB(file, RbName, RbVersion);
+ } catch (Exception exp) {
+ assert(true);
}
- catch (Exception exp)
- {
- assert(true);
- }
- }
+ }
@Test
public void createProfileTest() throws Exception {
String RbName = "rb";
String RbVersion = "p1";
ProfileEntity fE = new ProfileEntity();
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
- cnfAdapterRest.createProfile(fE, RbName, RbVersion);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
+ cnfAdapterRest.createProfile(fE, RbName, RbVersion);
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
String RbName = "rb";
String RbVersion = "p1";
String prName = "p";
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.getProfile(prName, RbName, RbVersion);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
String RbName = "rb";
String RbVersion = "p1";
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.getListOfProfile(RbName, RbVersion);
-}
-catch(Exception e)
-{
-assert(true);
-}
- }
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
+ }
@Test
public void deleteProfileTest() throws Exception {
String RbName = "rb";
String RbVersion = "p1";
String prName = "p";
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.deleteProfile(prName, RbName, RbVersion);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
MultipartFile file = Mockito.mock(MultipartFile.class);
Mockito.when(file.getOriginalFilename()).thenReturn("OK");
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
try {
cnfAdapterRest.uploadArtifactForProfile(file, RbName, RbVersion, prName);
- }
- catch(Exception exp)
- {
- assert(true);
+ } catch (Exception exp) {
+ assert(true);
}
- }
+ }
@Test
public void createConfigurationTest() throws Exception {
String RbVersion = "p1";
String prName = "p";
ConfigurationEntity cE = new ConfigurationEntity();
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.createConfiguration(cE, prName, RbName, RbVersion);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
String RbVersion = "p1";
String prName = "p";
String cfgName = "cfg";
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.getConfiguration(prName, RbName, RbVersion, cfgName);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
String RbVersion = "p1";
String prName = "p";
String cfgName = "cfg";
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.deleteConfiguration(prName, RbName, RbVersion, cfgName);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
String prName = "p";
String cfgName = "cfg";
ConfigurationEntity cE = new ConfigurationEntity();
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.updateConfiguration(cE, prName, RbName, RbVersion, cfgName);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
String RbVersion = "p1";
String prName = "p";
Tag tag = new Tag();
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.tagConfigurationValue(tag, RbName, RbVersion, prName);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
public void createConnectivityInfoTest() throws Exception {
ConnectivityInfo cIE = new ConnectivityInfo();
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.createConnectivityInfo(cIE);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
public void getConnectivityInfoTest() throws Exception {
String connName = "con";
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.getConnectivityInfo(connName);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
public void deleteConnectivityInfoTest() throws Exception {
String connName = "con";
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.deleteConnectivityInfo(connName);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
String RbName = "rb";
String RbVersion = "p1";
ConfigTemplateEntity tE = new ConfigTemplateEntity();
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.createConfigTemplate(tE, RbName, RbVersion);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
String RbName = "rb";
String RbVersion = "p1";
String tName = "t";
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.getConfigTemplate(RbName, RbVersion, tName);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
String RbName = "rb";
String RbVersion = "p1";
String tName = "t";
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.deleteTemplate(RbName, RbVersion, tName);
-}
-catch(Exception e)
-{
- assert(true);
-}
-
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
@Test
String tName = "t";
MultipartFile file = Mockito.mock(MultipartFile.class);
Mockito.when(file.getOriginalFilename()).thenReturn("First value");
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
try {
cnfAdapterRest.uploadTarFileForTemplate(file, RbName, RbVersion, tName);
- }
- catch (Exception exp)
- {
- assert(true);
+ } catch (Exception exp) {
+ assert(true);
}
}
String RbName = "rb";
String RbVersion = "p1";
String prName = "p";
- ReflectionTestUtils.setField(cnfAdapterRest,"uri","http://localhost");
-try{
+ // ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
+ try{
cnfAdapterRest.rollbackConfiguration(rE, RbName, RbVersion, prName);
-}
-catch(Exception e)
-{
-assert(true);
-}
+ }
+ catch(Exception e)
+ {
+ assert(true);
+ }
}
}