1 package org.onap.appc.data.services.node;
3 import com.fasterxml.jackson.databind.JsonNode;
4 import com.fasterxml.jackson.databind.ObjectMapper;
5 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
6 import java.util.HashMap;
7 import static org.junit.Assert.assertEquals;
8 import static org.junit.Assert.assertFalse;
9 import org.junit.Before;
10 import org.junit.Rule;
11 import org.junit.Test;
12 import org.junit.rules.ExpectedException;
13 import static org.mockito.Matchers.anyString;
14 import static org.mockito.Matchers.eq;
15 import static org.mockito.Mockito.mock;
16 import static org.mockito.Mockito.verify;
17 import static org.mockito.Mockito.when;
18 import org.onap.appc.data.services.AppcDataServiceConstant;
19 import org.onap.appc.data.services.db.DGGeneralDBService;
20 import static org.onap.appc.data.services.node.ConfigResourceNode.CONFIG_FILE_ID_PARAM;
21 import static org.onap.appc.data.services.node.ConfigResourceNode.CONF_ACTION_PREFIX;
22 import static org.onap.appc.data.services.node.ConfigResourceNode.DEVICE_CONF_FILE_TYPE;
23 import static org.onap.appc.data.services.node.ConfigResourceNode.DEVICE_CONF_PREFIX;
24 import static org.onap.appc.data.services.node.ConfigResourceNode.DEVICE_PROTOCOL_PREFIX;
25 import static org.onap.appc.data.services.node.ConfigResourceNode.FAILURE_FILE_TYPE;
26 import static org.onap.appc.data.services.node.ConfigResourceNode.FAILURE_PREFIX;
27 import static org.onap.appc.data.services.node.ConfigResourceNode.FILE_CATEGORY_PARAM;
28 import static org.onap.appc.data.services.node.ConfigResourceNode.LOG_FILE_TYPE;
29 import static org.onap.appc.data.services.node.ConfigResourceNode.LOG_PREFIX;
30 import static org.onap.appc.data.services.node.ConfigResourceNode.MAX_CONF_FILE_PREFIX;
31 import static org.onap.appc.data.services.node.ConfigResourceNode.PREPARE_RELATIONSHIP_PARAM;
32 import static org.onap.appc.data.services.node.ConfigResourceNode.SDC_IND;
33 import static org.onap.appc.data.services.node.ConfigResourceNode.SITE_LOCATION_PARAM;
34 import static org.onap.appc.data.services.node.ConfigResourceNode.SUCCESS_FILE_TYPE;
35 import static org.onap.appc.data.services.node.ConfigResourceNode.SUCCESS_PREFIX;
36 import static org.onap.appc.data.services.node.ConfigResourceNode.CONFIG_FILES_PREFIX;
37 import static org.onap.appc.data.services.node.ConfigResourceNode.UPLOAD_CONFIG_ID_PARAM;
38 import static org.onap.appc.data.services.node.ConfigResourceNode.UPLOAD_CONFIG_INFO_PREFIX;
39 import static org.onap.appc.data.services.node.ConfigResourceNode.UPLOAD_CONFIG_PREFIX;
40 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
41 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
42 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
44 public class ConfigResourceNodeTest {
46 private HashMap<String, String> inParams;
47 private SvcLogicContext contextMock;
50 public ExpectedException expectedException = ExpectedException.none();
54 contextMock = mock(SvcLogicContext.class);
55 inParams = new HashMap<>();
61 * {"capabilities":{"vnfc":[],"vm":[{"ConfigureTest":["SSC","MMSC"]}],"vf-module":[],"vnf":["ConfigModify","HealthCheck"]}}
64 public void shouldProcessCapabilitiesForVMLevel() throws Exception {
65 SvcLogicContext ctx = new SvcLogicContext();
66 ConfigResourceNode node = new ConfigResourceNode(DGGeneralDBService.initialise());
67 String findCapability = "Restart";
68 JsonNodeFactory.instance.objectNode();
69 String subCaps = "[{\"Restart\":[\"SSC\",\"MMC\"]},{\"Rebuild\":[\"SSC\"]},{\"Migrate\":[\"SSC\"]},{\"Snapshot\":[\"SSC\"]},{\"Start\":[\"SSC\"]},{\"Stop\":[\"SSC\"]}]";
70 ObjectMapper m = new ObjectMapper();
71 JsonNode subCapabilities = m.readTree(subCaps);
72 String vServerId = "testServer";
73 ctx.setAttribute("tmp.vnfInfo.vm.vnfc.vnfc-function-code", "MMC");
74 ctx.setAttribute("tmp.vnfInfo.vm.vnfc.vnfc-name", "testVnfc");
75 node.processCapabilitiesForVMLevel(vServerId, ctx, findCapability, subCapabilities);
76 String result = ctx.getAttribute("capabilities");
77 assertEquals(result, "Supported");
81 public void shouldCheckIfCapabilityCheckNeeded() {
82 ConfigResourceNode node = new ConfigResourceNode(DGGeneralDBService.initialise());
83 String findCapability = "Start";
84 String capLevel = "vnf";
85 boolean result = node.checkIfCapabilityCheckNeeded(capLevel, findCapability);
90 public void should_add_attribute_with_success_if_get_config_file_succeed() throws SvcLogicException {
91 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder().build();
93 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
94 configResourceNode.getConfigFileReference(inParams, contextMock);
96 verify(contextMock).setAttribute(anyString(), eq(AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS));
100 public void should_add_attribute_with_success_if_get_config_info_succeed() throws SvcLogicException {
101 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder().build();
103 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
104 configResourceNode.getCommonConfigInfo(inParams, contextMock);
106 verify(contextMock).setAttribute(anyString(), eq(AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS));
110 public void should_add_attribute_with_success_if_get_template_succeed() throws SvcLogicException {
111 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder().build();
113 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
114 configResourceNode.getTemplate(inParams, contextMock);
116 verify(contextMock).setAttribute(anyString(), eq(AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS));
120 public void should_add_attribute_with_success_if_save_config_files_succeed() throws SvcLogicException {
121 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder().build();
123 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
124 configResourceNode.saveConfigFiles(inParams, contextMock);
126 verify(contextMock).setAttribute(anyString(), eq(AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS));
130 public void should_add_attribute_with_success_if_update_upload_config_succeed() throws SvcLogicException {
131 when(contextMock.getAttribute(UPLOAD_CONFIG_ID_PARAM)).thenReturn("1234");
133 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder().build();
135 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
136 configResourceNode.updateUploadConfig(inParams, contextMock);
138 verify(contextMock).setAttribute(anyString(), eq(AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS));
142 public void should_add_attribute_with_success_if_get_download_config_template_by_vnf_type_succeed() throws SvcLogicException {
143 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder().build();
145 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
146 configResourceNode.getDownloadConfigTemplateByVnf(inParams, contextMock);
148 verify(contextMock).setAttribute(anyString(), eq(AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS));
152 public void should_add_attribute_with_success_if_get_ssm_chain_succeed() throws SvcLogicException {
153 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder().build();
155 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
156 configResourceNode.getSmmChainKeyFiles(inParams, contextMock);
158 verify(contextMock).setAttribute(anyString(), eq(AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS));
162 public void should_throw_exception_on_device_config_missing() throws Exception {
163 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
164 .getConfigFileReferenceByFileTypeNVnfType(DEVICE_CONF_PREFIX, DEVICE_CONF_FILE_TYPE, SvcLogicResource.QueryStatus.NOT_FOUND)
167 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
169 expectedException.expect(SvcLogicException.class);
170 expectedException.expectMessage("Unable to Read ConfigFileReference:device-configuration");
171 configResourceNode.getConfigFileReference(inParams, contextMock);
175 public void should_throw_exception_on_device_config_failure() throws Exception {
176 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
177 .getConfigFileReferenceByFileTypeNVnfType(DEVICE_CONF_PREFIX, DEVICE_CONF_FILE_TYPE, SvcLogicResource.QueryStatus.FAILURE)
180 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
182 expectedException.expect(SvcLogicException.class);
183 expectedException.expectMessage("Unable to Read ConfigFileReference:device-configuration");
184 configResourceNode.getConfigFileReference(inParams, contextMock);
188 public void should_throw_exception_on_success_param_missing() throws Exception {
190 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
191 .getConfigFileReferenceByFileTypeNVnfType(SUCCESS_PREFIX, SUCCESS_FILE_TYPE, SvcLogicResource.QueryStatus.NOT_FOUND)
194 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
196 expectedException.expect(SvcLogicException.class);
197 expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_success");
198 configResourceNode.getConfigFileReference(inParams, contextMock);
202 public void should_throw_exception_on_success_param_failure() throws Exception {
203 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
204 .getConfigFileReferenceByFileTypeNVnfType(SUCCESS_PREFIX, SUCCESS_FILE_TYPE, SvcLogicResource.QueryStatus.FAILURE)
207 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
209 expectedException.expect(SvcLogicException.class);
210 expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_success");
211 configResourceNode.getConfigFileReference(inParams, contextMock);
215 public void should_throw_exception_on_failure_param_missing() throws Exception {
217 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
218 .getConfigFileReferenceByFileTypeNVnfType(FAILURE_PREFIX, FAILURE_FILE_TYPE, SvcLogicResource.QueryStatus.NOT_FOUND)
221 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
223 expectedException.expect(SvcLogicException.class);
224 expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_error");
225 configResourceNode.getConfigFileReference(inParams, contextMock);
229 public void should_throw_exception_on_failure_param_failure() throws Exception {
230 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
231 .getConfigFileReferenceByFileTypeNVnfType(FAILURE_PREFIX, FAILURE_FILE_TYPE, SvcLogicResource.QueryStatus.FAILURE)
234 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
236 expectedException.expect(SvcLogicException.class);
237 expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_error");
238 configResourceNode.getConfigFileReference(inParams, contextMock);
242 public void should_throw_exception_on_log_param_missing() throws Exception {
244 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
245 .getConfigFileReferenceByFileTypeNVnfType(LOG_PREFIX, LOG_FILE_TYPE, SvcLogicResource.QueryStatus.NOT_FOUND)
248 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
250 expectedException.expect(SvcLogicException.class);
251 expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_log");
252 configResourceNode.getConfigFileReference(inParams, contextMock);
256 public void should_throw_exception_on_log_param_failure() throws Exception {
257 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
258 .getConfigFileReferenceByFileTypeNVnfType(LOG_PREFIX, LOG_FILE_TYPE, SvcLogicResource.QueryStatus.FAILURE)
261 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
263 expectedException.expect(SvcLogicException.class);
264 expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_log");
265 configResourceNode.getConfigFileReference(inParams, contextMock);
269 public void should_throw_exception_on_device_protocol_missing() throws SvcLogicException {
270 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
271 .getDeviceProtocolByVnfType(DEVICE_PROTOCOL_PREFIX, SvcLogicResource.QueryStatus.NOT_FOUND)
274 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
276 expectedException.expect(SvcLogicException.class);
277 expectedException.expectMessage("Unable to Read device_interface_protocol");
278 configResourceNode.getCommonConfigInfo(inParams, contextMock);
282 public void should_throw_exception_on_device_protocol_failure() throws SvcLogicException {
283 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
284 .getDeviceProtocolByVnfType(DEVICE_PROTOCOL_PREFIX, SvcLogicResource.QueryStatus.FAILURE)
287 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
289 expectedException.expect(SvcLogicException.class);
290 expectedException.expectMessage("Unable to Read device_interface_protocol");
291 configResourceNode.getCommonConfigInfo(inParams, contextMock);
295 public void should_throw_exception_on_conf_action_by_vnf_action_failure() throws SvcLogicException {
296 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
297 .getConfigureActionDGByVnfTypeNAction(CONF_ACTION_PREFIX, SvcLogicResource.QueryStatus.FAILURE)
300 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
302 expectedException.expect(SvcLogicException.class);
303 expectedException.expectMessage("Unable to Read configure_action_dg");
304 configResourceNode.getCommonConfigInfo(inParams, contextMock);
308 public void should_throw_exception_on_conf_action_missing() throws SvcLogicException {
309 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
310 .getConfigureActionDGByVnfTypeNAction(CONF_ACTION_PREFIX, SvcLogicResource.QueryStatus.NOT_FOUND)
311 .getConfigureActionDGByVnfType(CONF_ACTION_PREFIX, SvcLogicResource.QueryStatus.NOT_FOUND)
314 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
316 expectedException.expect(SvcLogicException.class);
317 expectedException.expectMessage("Unable to Read configure_action_dg");
318 configResourceNode.getCommonConfigInfo(inParams, contextMock);
322 public void should_throw_exception_on_conf_action_failure() throws SvcLogicException {
323 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
324 .getConfigureActionDGByVnfTypeNAction(CONF_ACTION_PREFIX, SvcLogicResource.QueryStatus.NOT_FOUND)
325 .getConfigureActionDGByVnfType(CONF_ACTION_PREFIX, SvcLogicResource.QueryStatus.FAILURE)
328 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
330 expectedException.expect(SvcLogicException.class);
331 expectedException.expectMessage("Unable to Read configure_action_dg");
332 configResourceNode.getCommonConfigInfo(inParams, contextMock);
336 public void should_throw_exception_on_db_template_failure() throws SvcLogicException {
337 inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "some prefix");
338 inParams.put(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "some file category");
340 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
341 .getTemplate("some prefix", "some file category", SvcLogicResource.QueryStatus.FAILURE)
344 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
346 expectedException.expect(SvcLogicException.class);
347 expectedException.expectMessage("Unable to Read some file category");
348 configResourceNode.getTemplate(inParams, contextMock);
352 public void should_throw_exception_on_db_template_by_action_failure() throws SvcLogicException {
353 inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "some prefix");
354 inParams.put(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "some file category");
356 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
357 .getTemplate("some prefix", "some file category", SvcLogicResource.QueryStatus.NOT_FOUND)
358 .getTemplateByVnfTypeNAction("some prefix", "some file category", SvcLogicResource.QueryStatus.FAILURE)
361 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
363 expectedException.expect(SvcLogicException.class);
364 expectedException.expectMessage("Unable to Read some file category");
365 configResourceNode.getTemplate(inParams, contextMock);
369 public void should_throw_exception_on_db_template_by_action_missing() throws SvcLogicException {
370 inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "some prefix");
371 inParams.put(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "some file category");
373 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
374 .getTemplate("some prefix", "some file category", SvcLogicResource.QueryStatus.NOT_FOUND)
375 .getTemplateByVnfTypeNAction("some prefix", "some file category", SvcLogicResource.QueryStatus.NOT_FOUND)
378 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
380 expectedException.expect(SvcLogicException.class);
381 expectedException.expectMessage("Unable to Read some file category");
382 configResourceNode.getTemplate(inParams, contextMock);
386 public void should_throw_exception_on_db_template_by_name_missing() throws SvcLogicException {
387 inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "some prefix");
388 inParams.put(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "some file category");
390 SvcLogicContext context = new SvcLogicContext();
391 context.setAttribute("template-name", "test template");
393 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
394 .getTemplateByTemplateName("some prefix", "test template", SvcLogicResource.QueryStatus.NOT_FOUND)
397 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
399 expectedException.expect(SvcLogicException.class);
400 expectedException.expectMessage("Unable to Read some file category template");
401 configResourceNode.getTemplate(inParams, context);
405 public void should_throw_exception_on_db_template_by_name_failure() throws SvcLogicException {
406 inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "some prefix");
407 inParams.put(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "some file category");
409 SvcLogicContext context = new SvcLogicContext();
410 context.setAttribute("template-name", "test template");
412 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
413 .getTemplateByTemplateName("some prefix", "test template", SvcLogicResource.QueryStatus.FAILURE)
416 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
418 expectedException.expect(SvcLogicException.class);
419 expectedException.expectMessage("Unable to Read some file category template");
420 configResourceNode.getTemplate(inParams, context);
424 public void should_throw_exception_on_save_config_failure() throws SvcLogicException {
425 SvcLogicContext context = new SvcLogicContext();
426 context.setAttribute(FILE_CATEGORY_PARAM, "some file category");
428 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
429 .saveConfigFiles(CONFIG_FILES_PREFIX, SvcLogicResource.QueryStatus.FAILURE)
432 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
434 expectedException.expect(SvcLogicException.class);
435 expectedException.expectMessage("Unable to Save some file category in configfiles");
436 configResourceNode.saveConfigFiles(inParams, context);
440 public void should_throw_exception_on_get_max_config_id_missing() throws SvcLogicException {
441 SvcLogicContext context = new SvcLogicContext();
442 context.setAttribute(FILE_CATEGORY_PARAM, "some file category");
444 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
445 .getMaxConfigFileId(MAX_CONF_FILE_PREFIX, "some file category", SvcLogicResource.QueryStatus.NOT_FOUND)
448 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
450 expectedException.expect(SvcLogicException.class);
451 expectedException.expectMessage("Unable to get some file category from configfiles");
453 configResourceNode.saveConfigFiles(inParams, context);
457 public void should_throw_exception_on_save_config_files_failure() throws SvcLogicException {
458 SvcLogicContext context = new SvcLogicContext();
459 context.setAttribute(CONFIG_FILE_ID_PARAM, "some file id");
461 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
462 .savePrepareRelationship(PREPARE_RELATIONSHIP_PARAM, "some file id", SDC_IND, SvcLogicResource.QueryStatus.FAILURE)
465 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
467 expectedException.expect(SvcLogicException.class);
468 expectedException.expectMessage("Unable to save prepare_relationship");
469 configResourceNode.saveConfigFiles(inParams, context);
473 public void should_throw_exception_on_save_upload_config_failure() throws SvcLogicException {
474 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
475 .saveUploadConfig(UPLOAD_CONFIG_PREFIX, SvcLogicResource.QueryStatus.FAILURE)
478 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
480 expectedException.expect(SvcLogicException.class);
481 expectedException.expectMessage("Unable to Save configuration in upload_config");
482 configResourceNode.updateUploadConfig(inParams, contextMock);
486 public void should_throw_exception_on_get_upload_config_failure() throws SvcLogicException {
487 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
488 .getUploadConfigInfo(UPLOAD_CONFIG_INFO_PREFIX, SvcLogicResource.QueryStatus.FAILURE)
491 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
493 expectedException.expect(SvcLogicException.class);
494 expectedException.expectMessage("Unable to get record from upload_config");
495 configResourceNode.updateUploadConfig(inParams, contextMock);
499 public void should_throw_exception_on_get_upload_config_missing() throws SvcLogicException {
500 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
501 .getUploadConfigInfo(UPLOAD_CONFIG_INFO_PREFIX, SvcLogicResource.QueryStatus.NOT_FOUND)
504 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
506 expectedException.expect(SvcLogicException.class);
507 expectedException.expectMessage("Unable to get record from upload_config");
508 configResourceNode.updateUploadConfig(inParams, contextMock);
512 public void should_throw_exception_on_update_upload_config_failure() throws SvcLogicException {
513 when(contextMock.getAttribute(UPLOAD_CONFIG_ID_PARAM)).thenReturn("1234");
515 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
516 .updateUploadConfig(UPLOAD_CONFIG_PREFIX, 1234, SvcLogicResource.QueryStatus.FAILURE)
519 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
521 expectedException.expect(SvcLogicException.class);
522 expectedException.expectMessage("Unable to upload upload_config");
523 configResourceNode.updateUploadConfig(inParams, contextMock);
527 public void should_throw_exception_on_get_download_config_failure() throws SvcLogicException {
528 inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "some prefix");
530 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
531 .getDownloadConfigTemplateByVnf("some prefix", SvcLogicResource.QueryStatus.FAILURE)
534 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
536 expectedException.expect(SvcLogicException.class);
537 expectedException.expectMessage("Unable to get download config template.");
538 configResourceNode.getDownloadConfigTemplateByVnf(inParams, contextMock);
542 public void should_throw_exception_on_get_ssm_chain_failure() throws SvcLogicException {
543 when(contextMock.getAttribute(SITE_LOCATION_PARAM)).thenReturn("some location");
545 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
546 .getTemplateByArtifactType("smm", "smm", "some location", SvcLogicResource.QueryStatus.FAILURE)
549 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
551 expectedException.expect(SvcLogicException.class);
552 expectedException.expectMessage("Unable to Read smm file");
553 configResourceNode.getSmmChainKeyFiles(inParams, contextMock);
557 public void should_throw_exception_on_get_ca_chain_failure() throws SvcLogicException {
558 when(contextMock.getAttribute(SITE_LOCATION_PARAM)).thenReturn("some location");
560 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
561 .getTemplateByArtifactType("intermediate-ca-chain", "intermediate_ca_chain", "some location", SvcLogicResource.QueryStatus.FAILURE)
564 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
566 expectedException.expect(SvcLogicException.class);
567 expectedException.expectMessage("Unable to Read intermediate_ca_chain file");
568 configResourceNode.getSmmChainKeyFiles(inParams, contextMock);
572 public void should_throw_exception_on_get_server_certificate_and_key_failure() throws SvcLogicException {
573 when(contextMock.getAttribute(SITE_LOCATION_PARAM)).thenReturn("some location");
575 DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
576 .getTemplateByArtifactType("server-certificate-and-key", "server_certificate_and_key", "some location", SvcLogicResource.QueryStatus.FAILURE)
579 ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
581 expectedException.expect(SvcLogicException.class);
582 expectedException.expectMessage("Unable to Read server_certificate_and_key file");
583 configResourceNode.getSmmChainKeyFiles(inParams, contextMock);