2da8d5316a57513fa641f7dd55e17addbb0989a9
[appc.git] /
1 package org.onap.appc.data.services.node;
2
3 import static org.mockito.Matchers.any;
4 import static org.mockito.Matchers.eq;
5 import static org.mockito.Mockito.doReturn;
6 import static org.mockito.Mockito.mock;
7 import org.onap.appc.data.services.db.DGGeneralDBService;
8 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
9 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
10 import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
11
12 class MockDbServiceBuilder {
13
14     private final DGGeneralDBService dbServiceMock;
15
16     MockDbServiceBuilder() throws SvcLogicException {
17         dbServiceMock = mock(DGGeneralDBService.class);
18     }
19
20     MockDbServiceBuilder getConfigFileReferenceByFileTypeNVnfType(String prefix, String fileType, SvcLogicResource.QueryStatus status) throws SvcLogicException {
21         doReturn(status)
22             .when(dbServiceMock)
23             .getConfigFileReferenceByFileTypeNVnfType(any(SvcLogicContext.class), eq(prefix), eq(fileType));
24
25         return this;
26     }
27
28     public MockDbServiceBuilder getDeviceProtocolByVnfType(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
29         doReturn(status)
30             .when(dbServiceMock)
31             .getDeviceProtocolByVnfType(any(SvcLogicContext.class), eq(prefix));
32
33         return this;
34     }
35
36     public MockDbServiceBuilder getConfigureActionDGByVnfTypeNAction(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
37         doReturn(status)
38             .when(dbServiceMock)
39             .getConfigureActionDGByVnfTypeNAction(any(SvcLogicContext.class), eq(prefix));
40
41         return this;
42     }
43
44     public MockDbServiceBuilder getConfigureActionDGByVnfType(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
45         doReturn(status)
46             .when(dbServiceMock)
47             .getConfigureActionDGByVnfType(any(SvcLogicContext.class), eq(prefix));
48
49         return this;
50     }
51
52     public MockDbServiceBuilder getTemplate(String prefix, String fileCategory, SvcLogicResource.QueryStatus status) throws SvcLogicException {
53         doReturn(status)
54             .when(dbServiceMock)
55             .getTemplate(any(SvcLogicContext.class), eq(prefix), eq(fileCategory));
56
57         return this;
58     }
59
60     public MockDbServiceBuilder getTemplateByVnfTypeNAction(String prefix, String fileCategory, SvcLogicResource.QueryStatus status) throws SvcLogicException {
61         doReturn(status)
62             .when(dbServiceMock)
63             .getTemplateByVnfTypeNAction(any(SvcLogicContext.class), eq(prefix), eq(fileCategory));
64
65         return this;
66     }
67
68     public MockDbServiceBuilder getTemplateByTemplateName(String prefix, String fileCategory, SvcLogicResource.QueryStatus status) throws SvcLogicException {
69         doReturn(status)
70             .when(dbServiceMock)
71             .getTemplateByTemplateName(any(SvcLogicContext.class), eq(prefix), eq(fileCategory));
72
73         return this;
74     }
75
76     public MockDbServiceBuilder saveConfigFiles(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
77         doReturn(status)
78             .when(dbServiceMock)
79             .saveConfigFiles(any(SvcLogicContext.class), eq(prefix));
80
81         return this;
82     }
83
84     public MockDbServiceBuilder getMaxConfigFileId(String prefix, String fileCategory, SvcLogicResource.QueryStatus status) throws SvcLogicException {
85         doReturn(status)
86             .when(dbServiceMock)
87             .getMaxConfigFileId(any(SvcLogicContext.class), eq(prefix), eq(fileCategory));
88
89         return this;
90     }
91
92     public MockDbServiceBuilder savePrepareRelationship(String prefix, String field, String sdnc, SvcLogicResource.QueryStatus status) throws SvcLogicException {
93         doReturn(status)
94             .when(dbServiceMock)
95             .savePrepareRelationship(any(SvcLogicContext.class), eq(prefix), eq(field), eq(sdnc));
96
97         return this;
98     }
99
100     public MockDbServiceBuilder saveUploadConfig(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
101         doReturn(status)
102             .when(dbServiceMock)
103             .saveUploadConfig(any(SvcLogicContext.class), eq(prefix));
104
105         return this;
106     }
107
108     public MockDbServiceBuilder getUploadConfigInfo(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
109         doReturn(status)
110             .when(dbServiceMock)
111             .getUploadConfigInfo(any(SvcLogicContext.class), eq(prefix));
112
113         return this;
114     }
115
116     public MockDbServiceBuilder updateUploadConfig(String prefix, int maxId, SvcLogicResource.QueryStatus status) throws SvcLogicException {
117         doReturn(status)
118             .when(dbServiceMock)
119             .updateUploadConfig(any(SvcLogicContext.class), eq(prefix), eq(maxId));
120
121         return this;
122     }
123
124     public MockDbServiceBuilder getDownloadConfigTemplateByVnf(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
125         doReturn(status)
126             .when(dbServiceMock)
127             .getDownloadConfigTemplateByVnf(any(SvcLogicContext.class), eq(prefix));
128
129         return this;
130     }
131
132     public MockDbServiceBuilder getTemplateByArtifactType(String prefix, String fileCategory, String artifactType, SvcLogicResource.QueryStatus status) throws SvcLogicException {
133         doReturn(status)
134             .when(dbServiceMock)
135             .getTemplateByArtifactType(any(SvcLogicContext.class), eq(prefix), eq(fileCategory), eq(artifactType));
136
137         return this;
138     }
139
140     DGGeneralDBService build() {
141         return dbServiceMock;
142     }
143 }