Add coverage for ConfigResourceNode-4
[appc.git] / appc-config / appc-data-services / provider / src / test / java / org / onap / appc / data / services / node / ConfigResourceNodeTest.java
1 package org.onap.appc.data.services.node;
2
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.SUCCESS_FILE_TYPE;
34 import static org.onap.appc.data.services.node.ConfigResourceNode.SUCCESS_PREFIX;
35 import static org.onap.appc.data.services.node.ConfigResourceNode.CONFIG_FILES_PREFIX;
36 import static org.onap.appc.data.services.node.ConfigResourceNode.UPLOAD_CONFIG_ID_PARAM;
37 import static org.onap.appc.data.services.node.ConfigResourceNode.UPLOAD_CONFIG_INFO_PREFIX;
38 import static org.onap.appc.data.services.node.ConfigResourceNode.UPLOAD_CONFIG_PREFIX;
39 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
40 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
41 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
42
43 public class ConfigResourceNodeTest {
44
45     private HashMap<String, String> inParams;
46     private SvcLogicContext contextMock;
47
48     @Rule
49     public ExpectedException expectedException = ExpectedException.none();
50
51     @Before
52     public void setUp() {
53         contextMock = mock(SvcLogicContext.class);
54         inParams = new HashMap<>();
55     }
56
57     /**
58      * Example data:
59      * <p>
60      * {"capabilities":{"vnfc":[],"vm":[{"ConfigureTest":["SSC","MMSC"]}],"vf-module":[],"vnf":["ConfigModify","HealthCheck"]}}
61      */
62     @Test
63     public void shouldProcessCapabilitiesForVMLevel() throws Exception {
64         SvcLogicContext ctx = new SvcLogicContext();
65         ConfigResourceNode node = new ConfigResourceNode(DGGeneralDBService.initialise());
66         String findCapability = "Restart";
67         JsonNodeFactory.instance.objectNode();
68         String subCaps = "[{\"Restart\":[\"SSC\",\"MMC\"]},{\"Rebuild\":[\"SSC\"]},{\"Migrate\":[\"SSC\"]},{\"Snapshot\":[\"SSC\"]},{\"Start\":[\"SSC\"]},{\"Stop\":[\"SSC\"]}]";
69         ObjectMapper m = new ObjectMapper();
70         JsonNode subCapabilities = m.readTree(subCaps);
71         String vServerId = "testServer";
72         ctx.setAttribute("tmp.vnfInfo.vm.vnfc.vnfc-function-code", "MMC");
73         ctx.setAttribute("tmp.vnfInfo.vm.vnfc.vnfc-name", "testVnfc");
74         node.processCapabilitiesForVMLevel(vServerId, ctx, findCapability, subCapabilities);
75         String result = ctx.getAttribute("capabilities");
76         assertEquals(result, "Supported");
77     }
78
79     @Test
80     public void shouldCheckIfCapabilityCheckNeeded() {
81         ConfigResourceNode node = new ConfigResourceNode(DGGeneralDBService.initialise());
82         String findCapability = "Start";
83         String capLevel = "vnf";
84         boolean result = node.checkIfCapabilityCheckNeeded(capLevel, findCapability);
85         assertFalse(result);
86     }
87
88     @Test
89     public void should_add_attribute_with_success_if_get_config_file_succeed() throws SvcLogicException {
90         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder().build();
91
92         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
93         configResourceNode.getConfigFileReference(inParams, contextMock);
94
95         verify(contextMock).setAttribute(anyString(), eq(AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS));
96     }
97
98     @Test
99     public void should_add_attribute_with_success_if_get_config_info_succeed() throws SvcLogicException {
100         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder().build();
101
102         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
103         configResourceNode.getCommonConfigInfo(inParams, contextMock);
104
105         verify(contextMock).setAttribute(anyString(), eq(AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS));
106     }
107
108     @Test
109     public void should_add_attribute_with_success_if_get_template_succeed() throws SvcLogicException {
110         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder().build();
111
112         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
113         configResourceNode.getTemplate(inParams, contextMock);
114
115         verify(contextMock).setAttribute(anyString(), eq(AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS));
116     }
117
118     @Test
119     public void should_add_attribute_with_success_if_save_config_files_succeed() throws SvcLogicException {
120         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder().build();
121
122         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
123         configResourceNode.saveConfigFiles(inParams, contextMock);
124
125         verify(contextMock).setAttribute(anyString(), eq(AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS));
126     }
127
128     @Test
129     public void should_add_attribute_with_success_if_update_upload_config_succeed() throws SvcLogicException {
130         when(contextMock.getAttribute(UPLOAD_CONFIG_ID_PARAM)).thenReturn("1234");
131
132         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder().build();
133
134         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
135         configResourceNode.updateUploadConfig(inParams, contextMock);
136
137         verify(contextMock).setAttribute(anyString(), eq(AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS));
138     }
139
140     @Test
141     public void should_throw_exception_on_device_config_missing() throws Exception {
142         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
143             .getConfigFileReferenceByFileTypeNVnfType(DEVICE_CONF_PREFIX, DEVICE_CONF_FILE_TYPE, SvcLogicResource.QueryStatus.NOT_FOUND)
144             .build();
145
146         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
147
148         expectedException.expect(SvcLogicException.class);
149         expectedException.expectMessage("Unable to Read ConfigFileReference:device-configuration");
150         configResourceNode.getConfigFileReference(inParams, contextMock);
151     }
152
153     @Test
154     public void should_throw_exception_on_device_config_failure() throws Exception {
155         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
156             .getConfigFileReferenceByFileTypeNVnfType(DEVICE_CONF_PREFIX, DEVICE_CONF_FILE_TYPE, SvcLogicResource.QueryStatus.FAILURE)
157             .build();
158
159         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
160
161         expectedException.expect(SvcLogicException.class);
162         expectedException.expectMessage("Unable to Read ConfigFileReference:device-configuration");
163         configResourceNode.getConfigFileReference(inParams, contextMock);
164     }
165
166     @Test
167     public void should_throw_exception_on_success_param_missing() throws Exception {
168
169         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
170             .getConfigFileReferenceByFileTypeNVnfType(SUCCESS_PREFIX, SUCCESS_FILE_TYPE, SvcLogicResource.QueryStatus.NOT_FOUND)
171             .build();
172
173         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
174
175         expectedException.expect(SvcLogicException.class);
176         expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_success");
177         configResourceNode.getConfigFileReference(inParams, contextMock);
178     }
179
180     @Test
181     public void should_throw_exception_on_success_param_failure() throws Exception {
182         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
183             .getConfigFileReferenceByFileTypeNVnfType(SUCCESS_PREFIX, SUCCESS_FILE_TYPE, SvcLogicResource.QueryStatus.FAILURE)
184             .build();
185
186         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
187
188         expectedException.expect(SvcLogicException.class);
189         expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_success");
190         configResourceNode.getConfigFileReference(inParams, contextMock);
191     }
192
193     @Test
194     public void should_throw_exception_on_failure_param_missing() throws Exception {
195
196         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
197             .getConfigFileReferenceByFileTypeNVnfType(FAILURE_PREFIX, FAILURE_FILE_TYPE, SvcLogicResource.QueryStatus.NOT_FOUND)
198             .build();
199
200         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
201
202         expectedException.expect(SvcLogicException.class);
203         expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_error");
204         configResourceNode.getConfigFileReference(inParams, contextMock);
205     }
206
207     @Test
208     public void should_throw_exception_on_failure_param_failure() throws Exception {
209         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
210             .getConfigFileReferenceByFileTypeNVnfType(FAILURE_PREFIX, FAILURE_FILE_TYPE, SvcLogicResource.QueryStatus.FAILURE)
211             .build();
212
213         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
214
215         expectedException.expect(SvcLogicException.class);
216         expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_error");
217         configResourceNode.getConfigFileReference(inParams, contextMock);
218     }
219
220     @Test
221     public void should_throw_exception_on_log_param_missing() throws Exception {
222
223         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
224             .getConfigFileReferenceByFileTypeNVnfType(LOG_PREFIX, LOG_FILE_TYPE, SvcLogicResource.QueryStatus.NOT_FOUND)
225             .build();
226
227         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
228
229         expectedException.expect(SvcLogicException.class);
230         expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_log");
231         configResourceNode.getConfigFileReference(inParams, contextMock);
232     }
233
234     @Test
235     public void should_throw_exception_on_log_param_failure() throws Exception {
236         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
237             .getConfigFileReferenceByFileTypeNVnfType(LOG_PREFIX, LOG_FILE_TYPE, SvcLogicResource.QueryStatus.FAILURE)
238             .build();
239
240         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
241
242         expectedException.expect(SvcLogicException.class);
243         expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_log");
244         configResourceNode.getConfigFileReference(inParams, contextMock);
245     }
246
247     @Test
248     public void should_throw_exception_on_device_protocol_missing() throws SvcLogicException {
249         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
250             .getDeviceProtocolByVnfType(DEVICE_PROTOCOL_PREFIX, SvcLogicResource.QueryStatus.NOT_FOUND)
251             .build();
252
253         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
254
255         expectedException.expect(SvcLogicException.class);
256         expectedException.expectMessage("Unable to Read device_interface_protocol");
257         configResourceNode.getCommonConfigInfo(inParams, contextMock);
258     }
259
260     @Test
261     public void should_throw_exception_on_device_protocol_failure() throws SvcLogicException {
262         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
263             .getDeviceProtocolByVnfType(DEVICE_PROTOCOL_PREFIX, SvcLogicResource.QueryStatus.FAILURE)
264             .build();
265
266         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
267
268         expectedException.expect(SvcLogicException.class);
269         expectedException.expectMessage("Unable to Read device_interface_protocol");
270         configResourceNode.getCommonConfigInfo(inParams, contextMock);
271     }
272
273     @Test
274     public void should_throw_exception_on_conf_action_by_vnf_action_failure() throws SvcLogicException {
275         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
276             .getConfigureActionDGByVnfTypeNAction(CONF_ACTION_PREFIX, SvcLogicResource.QueryStatus.FAILURE)
277             .build();
278
279         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
280
281         expectedException.expect(SvcLogicException.class);
282         expectedException.expectMessage("Unable to Read configure_action_dg");
283         configResourceNode.getCommonConfigInfo(inParams, contextMock);
284     }
285
286     @Test
287     public void should_throw_exception_on_conf_action_missing() throws SvcLogicException {
288         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
289             .getConfigureActionDGByVnfTypeNAction(CONF_ACTION_PREFIX, SvcLogicResource.QueryStatus.NOT_FOUND)
290             .getConfigureActionDGByVnfType(CONF_ACTION_PREFIX, SvcLogicResource.QueryStatus.NOT_FOUND)
291             .build();
292
293         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
294
295         expectedException.expect(SvcLogicException.class);
296         expectedException.expectMessage("Unable to Read configure_action_dg");
297         configResourceNode.getCommonConfigInfo(inParams, contextMock);
298     }
299
300     @Test
301     public void should_throw_exception_on_conf_action_failure() throws SvcLogicException {
302         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
303             .getConfigureActionDGByVnfTypeNAction(CONF_ACTION_PREFIX, SvcLogicResource.QueryStatus.NOT_FOUND)
304             .getConfigureActionDGByVnfType(CONF_ACTION_PREFIX, SvcLogicResource.QueryStatus.FAILURE)
305             .build();
306
307         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
308
309         expectedException.expect(SvcLogicException.class);
310         expectedException.expectMessage("Unable to Read configure_action_dg");
311         configResourceNode.getCommonConfigInfo(inParams, contextMock);
312     }
313
314     @Test
315     public void should_throw_exception_on_db_template_failure() throws SvcLogicException {
316         inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "some prefix");
317         inParams.put(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "some file category");
318
319         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
320             .getTemplate("some prefix", "some file category", SvcLogicResource.QueryStatus.FAILURE)
321             .build();
322
323         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
324
325         expectedException.expect(SvcLogicException.class);
326         expectedException.expectMessage("Unable to Read some file category");
327         configResourceNode.getTemplate(inParams, contextMock);
328     }
329
330     @Test
331     public void should_throw_exception_on_db_template_by_action_failure() throws SvcLogicException {
332         inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "some prefix");
333         inParams.put(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "some file category");
334
335         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
336             .getTemplate("some prefix", "some file category", SvcLogicResource.QueryStatus.NOT_FOUND)
337             .getTemplateByVnfTypeNAction("some prefix", "some file category", SvcLogicResource.QueryStatus.FAILURE)
338             .build();
339
340         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
341
342         expectedException.expect(SvcLogicException.class);
343         expectedException.expectMessage("Unable to Read some file category");
344         configResourceNode.getTemplate(inParams, contextMock);
345     }
346
347     @Test
348     public void should_throw_exception_on_db_template_by_action_missing() throws SvcLogicException {
349         inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "some prefix");
350         inParams.put(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "some file category");
351
352         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
353             .getTemplate("some prefix", "some file category", SvcLogicResource.QueryStatus.NOT_FOUND)
354             .getTemplateByVnfTypeNAction("some prefix", "some file category", SvcLogicResource.QueryStatus.NOT_FOUND)
355             .build();
356
357         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
358
359         expectedException.expect(SvcLogicException.class);
360         expectedException.expectMessage("Unable to Read some file category");
361         configResourceNode.getTemplate(inParams, contextMock);
362     }
363
364     @Test
365     public void should_throw_exception_on_db_template_by_name_missing() throws SvcLogicException {
366         inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "some prefix");
367         inParams.put(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "some file category");
368
369         SvcLogicContext context = new SvcLogicContext();
370         context.setAttribute("template-name", "test template");
371
372         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
373             .getTemplateByTemplateName("some prefix", "test template", SvcLogicResource.QueryStatus.NOT_FOUND)
374             .build();
375
376         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
377
378         expectedException.expect(SvcLogicException.class);
379         expectedException.expectMessage("Unable to Read some file category template");
380         configResourceNode.getTemplate(inParams, context);
381     }
382
383     @Test
384     public void should_throw_exception_on_db_template_by_name_failure() throws SvcLogicException {
385         inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "some prefix");
386         inParams.put(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "some file category");
387
388         SvcLogicContext context = new SvcLogicContext();
389         context.setAttribute("template-name", "test template");
390
391         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
392             .getTemplateByTemplateName("some prefix", "test template", SvcLogicResource.QueryStatus.FAILURE)
393             .build();
394
395         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
396
397         expectedException.expect(SvcLogicException.class);
398         expectedException.expectMessage("Unable to Read some file category template");
399         configResourceNode.getTemplate(inParams, context);
400     }
401
402     @Test
403     public void should_throw_exception_on_save_config_failure() throws SvcLogicException {
404         SvcLogicContext context = new SvcLogicContext();
405         context.setAttribute(FILE_CATEGORY_PARAM, "some file category");
406
407         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
408             .saveConfigFiles(CONFIG_FILES_PREFIX, SvcLogicResource.QueryStatus.FAILURE)
409             .build();
410
411         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
412
413         expectedException.expect(SvcLogicException.class);
414         expectedException.expectMessage("Unable to Save some file category in configfiles");
415         configResourceNode.saveConfigFiles(inParams, context);
416     }
417
418     @Test
419     public void should_throw_exception_on_get_max_config_id_missing() throws SvcLogicException {
420         SvcLogicContext context = new SvcLogicContext();
421         context.setAttribute(FILE_CATEGORY_PARAM, "some file category");
422
423         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
424             .getMaxConfigFileId(MAX_CONF_FILE_PREFIX, "some file category", SvcLogicResource.QueryStatus.NOT_FOUND)
425             .build();
426
427         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
428
429         expectedException.expect(SvcLogicException.class);
430         expectedException.expectMessage("Unable to get some file category from configfiles");
431
432         configResourceNode.saveConfigFiles(inParams, context);
433     }
434
435     @Test
436     public void should_throw_exception_on_save_config_files_failure() throws SvcLogicException {
437         SvcLogicContext context = new SvcLogicContext();
438         context.setAttribute(CONFIG_FILE_ID_PARAM, "some file id");
439
440         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
441             .savePrepareRelationship(PREPARE_RELATIONSHIP_PARAM, "some file id", SDC_IND, SvcLogicResource.QueryStatus.FAILURE)
442             .build();
443
444         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
445
446         expectedException.expect(SvcLogicException.class);
447         expectedException.expectMessage("Unable to save prepare_relationship");
448         configResourceNode.saveConfigFiles(inParams, context);
449     }
450
451     @Test
452     public void should_throw_exception_on_save_upload_config_failure() throws SvcLogicException {
453         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
454             .saveUploadConfig(UPLOAD_CONFIG_PREFIX, SvcLogicResource.QueryStatus.FAILURE)
455             .build();
456
457         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
458
459         expectedException.expect(SvcLogicException.class);
460         expectedException.expectMessage("Unable to Save configuration in upload_config");
461         configResourceNode.updateUploadConfig(inParams, contextMock);
462     }
463
464     @Test
465     public void should_throw_exception_on_get_upload_config_failure() throws SvcLogicException {
466         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
467             .getUploadConfigInfo(UPLOAD_CONFIG_INFO_PREFIX, SvcLogicResource.QueryStatus.FAILURE)
468             .build();
469
470         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
471
472         expectedException.expect(SvcLogicException.class);
473         expectedException.expectMessage("Unable to get record from upload_config");
474         configResourceNode.updateUploadConfig(inParams, contextMock);
475     }
476
477     @Test
478     public void should_throw_exception_on_get_upload_config_missing() throws SvcLogicException {
479         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
480             .getUploadConfigInfo(UPLOAD_CONFIG_INFO_PREFIX, SvcLogicResource.QueryStatus.NOT_FOUND)
481             .build();
482
483         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
484
485         expectedException.expect(SvcLogicException.class);
486         expectedException.expectMessage("Unable to get record from upload_config");
487         configResourceNode.updateUploadConfig(inParams, contextMock);
488     }
489
490     @Test
491     public void should_throw_exception_on_update_upload_config_failure() throws SvcLogicException {
492         when(contextMock.getAttribute(UPLOAD_CONFIG_ID_PARAM)).thenReturn("1234");
493
494         DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
495             .updateUploadConfig(UPLOAD_CONFIG_PREFIX, 1234, SvcLogicResource.QueryStatus.FAILURE)
496             .build();
497
498         ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
499
500         expectedException.expect(SvcLogicException.class);
501         expectedException.expectMessage("Unable to upload upload_config");
502         configResourceNode.updateUploadConfig(inParams, contextMock);
503     }
504
505 }