Add coverage for ConfigResourceNode-3
[appc.git] / appc-config / appc-data-services / provider / src / test / java / org / onap / appc / data / services / node / MockDbServiceBuilder.java
1 package org.onap.appc.data.services.node;
2
3 import static org.mockito.Matchers.any;
4 import static org.mockito.Matchers.anyString;
5 import static org.mockito.Matchers.eq;
6 import static org.mockito.Mockito.doReturn;
7 import static org.mockito.Mockito.mock;
8 import org.onap.appc.data.services.db.DGGeneralDBService;
9 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
10 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
11 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
12
13 class MockDbServiceBuilder {
14
15     private final DGGeneralDBService dbServiceMock;
16
17     MockDbServiceBuilder() throws SvcLogicException {
18         dbServiceMock = mock(DGGeneralDBService.class);
19
20         doReturn(SvcLogicResource.QueryStatus.SUCCESS)
21             .when(dbServiceMock)
22             .getConfigFileReferenceByFileTypeNVnfType(any(SvcLogicContext.class), anyString(), anyString());
23     }
24
25     MockDbServiceBuilder getConfigFileReferenceByFileTypeNVnfType(String prefix, String fileType, SvcLogicResource.QueryStatus status) throws SvcLogicException {
26         doReturn(status)
27             .when(dbServiceMock)
28             .getConfigFileReferenceByFileTypeNVnfType(any(SvcLogicContext.class), eq(prefix), eq(fileType));
29
30         return this;
31     }
32
33     public MockDbServiceBuilder getDeviceProtocolByVnfType(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
34         doReturn(status)
35             .when(dbServiceMock)
36             .getDeviceProtocolByVnfType(any(SvcLogicContext.class), eq(prefix));
37
38         return this;
39     }
40
41     public MockDbServiceBuilder getConfigureActionDGByVnfTypeNAction(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
42         doReturn(status)
43             .when(dbServiceMock)
44             .getConfigureActionDGByVnfTypeNAction(any(SvcLogicContext.class), eq(prefix));
45
46         return this;
47     }
48
49     public MockDbServiceBuilder getConfigureActionDGByVnfType(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
50         doReturn(status)
51             .when(dbServiceMock)
52             .getConfigureActionDGByVnfType(any(SvcLogicContext.class), eq(prefix));
53
54         return this;
55     }
56
57     public MockDbServiceBuilder getTemplate(String prefix, String fileCategory, SvcLogicResource.QueryStatus status) throws SvcLogicException {
58         doReturn(status)
59             .when(dbServiceMock)
60             .getTemplate(any(SvcLogicContext.class), eq(prefix), eq(fileCategory));
61
62         return this;
63     }
64
65     public MockDbServiceBuilder getTemplateByVnfTypeNAction(String prefix, String fileCategory, SvcLogicResource.QueryStatus status) throws SvcLogicException {
66         doReturn(status)
67             .when(dbServiceMock)
68             .getTemplateByVnfTypeNAction(any(SvcLogicContext.class), eq(prefix), eq(fileCategory));
69
70         return this;
71     }
72
73     public MockDbServiceBuilder getTemplateByTemplateName(String prefix, String fileCategory, SvcLogicResource.QueryStatus status) throws SvcLogicException {
74         doReturn(status)
75             .when(dbServiceMock)
76             .getTemplateByTemplateName(any(SvcLogicContext.class), eq(prefix), eq(fileCategory));
77
78         return this;
79     }
80
81     public MockDbServiceBuilder saveConfigFiles(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
82         doReturn(status)
83             .when(dbServiceMock)
84             .saveConfigFiles(any(SvcLogicContext.class), eq(prefix));
85
86         return this;
87     }
88
89     public MockDbServiceBuilder getMaxConfigFileId(String prefix, String fileCategory, SvcLogicResource.QueryStatus status) throws SvcLogicException {
90         doReturn(status)
91             .when(dbServiceMock)
92             .getMaxConfigFileId(any(SvcLogicContext.class), eq(prefix), eq(fileCategory));
93
94         return this;
95     }
96
97     public MockDbServiceBuilder savePrepareRelationship(String prefix, String field, String sdnc, SvcLogicResource.QueryStatus status) throws SvcLogicException {
98         doReturn(status)
99             .when(dbServiceMock)
100             .savePrepareRelationship(any(SvcLogicContext.class), eq(prefix), eq(field), eq(sdnc));
101
102         return this;
103     }
104
105     DGGeneralDBService build() {
106         return dbServiceMock;
107     }
108 }