6
6
import com .sample .app .model .client .DocumentContent ;
7
7
import com .sample .app .model .client .DocumentDetail ;
8
8
import com .sample .app .model .client .StateType ;
9
- import com .sample .app .model .exception .ServiceException ;
10
9
import java .io .InputStream ;
11
10
import java .text .DecimalFormat ;
12
11
import java .util .ArrayList ;
21
20
/**
22
21
* Mock implementation for testing.
23
22
*/
24
- public class MockDataUtil {
23
+ public final class MockDataUtil {
25
24
26
25
private static final AtomicInteger CLIENT_IDS = new AtomicInteger (1 );
27
26
private static final Map <String , ClientDetail > CLIENTS = new HashMap <>();
@@ -37,16 +36,35 @@ public class MockDataUtil {
37
36
38
37
}
39
38
39
+ /**
40
+ * Private constructor.
41
+ */
42
+ private MockDataUtil () {
43
+ // Do nothing
44
+ }
45
+
46
+ /**
47
+ * @return the list of available table names
48
+ */
40
49
public static List <String > retrieveTableNames () {
41
50
return new ArrayList <>(TABLES .keySet ());
42
51
}
43
52
53
+ /**
54
+ * @param table the table name
55
+ * @return the code options for the table
56
+ */
44
57
public static List <CodeOption > retrieveTableCodes (final String table ) {
45
58
List <CodeOption > options = TABLES .get (table );
46
59
return options ;
47
60
}
48
61
49
- public static List <ClientDetail > searchClients (final String search ) throws ServiceException {
62
+ /**
63
+ *
64
+ * @param search the search criteria
65
+ * @return the matching clients
66
+ */
67
+ public static List <ClientDetail > searchClients (final String search ) {
50
68
51
69
List <ClientDetail > clients = new ArrayList <>();
52
70
@@ -60,28 +78,50 @@ public static List<ClientDetail> searchClients(final String search) throws Servi
60
78
return clients ;
61
79
}
62
80
81
+ /**
82
+ *
83
+ * @param clientId the client id to retrieve
84
+ * @return the client details
85
+ */
63
86
public static ClientDetail retrieveClient (final String clientId ) {
64
87
return CLIENTS .get (clientId );
65
88
}
66
89
67
- public static ClientDetail createClient (final ClientDetail detail ) throws ServiceException {
90
+ /**
91
+ *
92
+ * @param detail the client details to create
93
+ * @return the created client
94
+ */
95
+ public static ClientDetail createClient (final ClientDetail detail ) {
68
96
String id = "ORG" + CLIENT_IDS .getAndIncrement ();
69
97
detail .setClientId (id );
70
98
CLIENTS .put (id , detail );
71
99
return detail ;
72
100
}
73
101
74
- public static ClientDetail updateClient (final ClientDetail detail ) throws ServiceException {
102
+ /**
103
+ * @param detail the updated client details
104
+ * @return the client details
105
+ */
106
+ public static ClientDetail updateClient (final ClientDetail detail ) {
75
107
String key = detail .getClientId ();
76
108
CLIENTS .put (key , detail );
77
109
return detail ;
78
110
}
79
111
80
- public static void deleteClient (final String clientId ) throws ServiceException {
112
+ /**
113
+ *
114
+ * @param clientId the client id to delete
115
+ */
116
+ public static void deleteClient (final String clientId ) {
81
117
CLIENTS .remove (clientId );
82
118
// TODO Remove documents as well
83
119
}
84
120
121
+ /**
122
+ * @param clientId the client id to retrieve documents for
123
+ * @return the list of client documents
124
+ */
85
125
public static List <DocumentDetail > getOrCreateClientDocuments (final String clientId ) {
86
126
// Build mock list of document details
87
127
List <DocumentDetail > docs = CLIENT_DOCUMENTS .get (clientId );
@@ -95,10 +135,19 @@ public static List<DocumentDetail> getOrCreateClientDocuments(final String clien
95
135
return docs ;
96
136
}
97
137
138
+ /**
139
+ * @param documentId the document id to retrieve
140
+ * @return the document details
141
+ */
98
142
public static DocumentDetail retrieveDocument (final String documentId ) {
99
143
return DOCUMENTS .get (documentId );
100
144
}
101
145
146
+ /**
147
+ *
148
+ * @param doc the document content to retrieve
149
+ * @return the document content
150
+ */
102
151
public static DocumentContent retrieveContent (final DocumentDetail doc ) {
103
152
byte [] bytes = getDocumentBytes (doc );
104
153
String mime = getDocumentMimeType (doc );
@@ -126,10 +175,6 @@ private static Map<String, List<CodeOption>> createTables() {
126
175
return tables ;
127
176
}
128
177
129
- /**
130
- * @param idx the suffix
131
- * @return the detail
132
- */
133
178
private static ClientDetail createOrganisation (final int idx ) {
134
179
ClientDetail detail = new ClientDetail ();
135
180
detail .setClientId ("ORG" + idx );
@@ -140,10 +185,6 @@ private static ClientDetail createOrganisation(final int idx) {
140
185
return detail ;
141
186
}
142
187
143
- /**
144
- * @param idx the suffix
145
- * @return the detail
146
- */
147
188
private static AddressDetail createAddress (final int idx ) {
148
189
AddressDetail detail = new AddressDetail ();
149
190
detail .setCountryCode ("A" );
@@ -154,9 +195,6 @@ private static AddressDetail createAddress(final int idx) {
154
195
return detail ;
155
196
}
156
197
157
- /**
158
- * @return the mock documents
159
- */
160
198
private static List <DocumentDetail > createDocuments (final String clientId ) {
161
199
// Build mock list of document details
162
200
List <DocumentDetail > docs = new ArrayList <>();
0 commit comments