1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
package org.onap.appc.data.services.node;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import org.onap.appc.data.services.db.DGGeneralDBService;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
class MockDbServiceBuilder {
private final DGGeneralDBService dbServiceMock;
MockDbServiceBuilder() throws SvcLogicException {
dbServiceMock = mock(DGGeneralDBService.class);
doReturn(SvcLogicResource.QueryStatus.SUCCESS)
.when(dbServiceMock)
.getConfigFileReferenceByFileTypeNVnfType(any(SvcLogicContext.class), anyString(), anyString());
}
MockDbServiceBuilder getConfigFileReferenceByFileTypeNVnfType(String prefix, String fileType, SvcLogicResource.QueryStatus status) throws SvcLogicException {
doReturn(status)
.when(dbServiceMock)
.getConfigFileReferenceByFileTypeNVnfType(any(SvcLogicContext.class), eq(prefix), eq(fileType));
return this;
}
public MockDbServiceBuilder getDeviceProtocolByVnfType(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
doReturn(status)
.when(dbServiceMock)
.getDeviceProtocolByVnfType(any(SvcLogicContext.class), eq(prefix));
return this;
}
public MockDbServiceBuilder getConfigureActionDGByVnfTypeNAction(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
doReturn(status)
.when(dbServiceMock)
.getConfigureActionDGByVnfTypeNAction(any(SvcLogicContext.class), eq(prefix));
return this;
}
public MockDbServiceBuilder getConfigureActionDGByVnfType(String prefix, SvcLogicResource.QueryStatus status) throws SvcLogicException {
doReturn(status)
.when(dbServiceMock)
.getConfigureActionDGByVnfType(any(SvcLogicContext.class), eq(prefix));
return this;
}
public MockDbServiceBuilder getTemplate(String prefix, String fileCategory, SvcLogicResource.QueryStatus status) throws SvcLogicException {
doReturn(status)
.when(dbServiceMock)
.getTemplate(any(SvcLogicContext.class), eq(prefix), eq(fileCategory));
return this;
}
public MockDbServiceBuilder getTemplateByVnfTypeNAction(String prefix, String fileCategory, SvcLogicResource.QueryStatus status) throws SvcLogicException {
doReturn(status)
.when(dbServiceMock)
.getTemplateByVnfTypeNAction(any(SvcLogicContext.class), eq(prefix), eq(fileCategory));
return this;
}
public MockDbServiceBuilder getTemplateByTemplateName(String prefix, String fileCategory, SvcLogicResource.QueryStatus status) throws SvcLogicException {
doReturn(status)
.when(dbServiceMock)
.getTemplateByTemplateName(any(SvcLogicContext.class), eq(prefix), eq(fileCategory));
return this;
}
DGGeneralDBService build() {
return dbServiceMock;
}
}
|