Remove version from PdpGroup
[policy/models.git] / models-pdp / src / test / java / org / onap / policy / models / pdp / persistence / provider / PdpProviderTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.models.pdp.persistence.provider;
23
24 import static org.assertj.core.api.Assertions.assertThatThrownBy;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotEquals;
27 import static org.junit.Assert.assertTrue;
28
29 import java.util.ArrayList;
30 import java.util.List;
31 import java.util.Properties;
32
33 import org.eclipse.persistence.config.PersistenceUnitProperties;
34 import org.junit.After;
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.onap.policy.common.utils.coder.StandardCoder;
38 import org.onap.policy.common.utils.resources.ResourceUtils;
39 import org.onap.policy.models.base.PfModelException;
40 import org.onap.policy.models.dao.DaoParameters;
41 import org.onap.policy.models.dao.PfDao;
42 import org.onap.policy.models.dao.PfDaoFactory;
43 import org.onap.policy.models.dao.impl.DefaultPfDao;
44 import org.onap.policy.models.pdp.concepts.Pdp;
45 import org.onap.policy.models.pdp.concepts.PdpGroup;
46 import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
47 import org.onap.policy.models.pdp.concepts.PdpGroups;
48 import org.onap.policy.models.pdp.concepts.PdpStatistics;
49 import org.onap.policy.models.pdp.concepts.PdpSubGroup;
50 import org.onap.policy.models.pdp.enums.PdpHealthStatus;
51 import org.onap.policy.models.pdp.enums.PdpState;
52 import org.onap.policy.models.pdp.persistence.provider.PdpProvider;
53 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
54 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
55 import org.onap.policy.models.tosca.simple.provider.SimpleToscaProvider;
56
57 /**
58  * Test the {@link SimpleToscaProvider} class.
59  *
60  * @author Liam Fallon (liam.fallon@est.tech)
61  */
62 public class PdpProviderTest {
63     private PfDao pfDao;
64     private StandardCoder standardCoder;
65
66
67     /**
68      * Set up the DAO towards the database.
69      *
70      * @throws Exception on database errors
71      */
72     @Before
73     public void setupDao() throws Exception {
74         final DaoParameters daoParameters = new DaoParameters();
75         daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
76
77         daoParameters.setPersistenceUnit("ToscaConceptTest");
78
79         Properties jdbcProperties = new Properties();
80         jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
81         jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "P01icY");
82
83         // H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
84         jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
85         jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
86
87         daoParameters.setJdbcProperties(jdbcProperties );
88
89         pfDao = new PfDaoFactory().createPfDao(daoParameters);
90         pfDao.init(daoParameters);
91     }
92
93     /**
94      * Set up GSON.
95      */
96     @Before
97     public void setupGson() {
98         standardCoder = new StandardCoder();
99     }
100
101     @After
102     public void teardown() throws Exception {
103         pfDao.close();
104     }
105
106     @Test
107     public void testGroupsGet() throws Exception {
108         assertThatThrownBy(() -> {
109             new PdpProvider().getPdpGroups(null, null);
110         }).hasMessage("dao is marked @NonNull but is null");
111
112         assertThatThrownBy(() -> {
113             new PdpProvider().getPdpGroups(null, "name");
114         }).hasMessage("dao is marked @NonNull but is null");
115
116         String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json");
117         PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class);
118
119         PdpGroups createdPdpGroups0 = new PdpGroups();
120         createdPdpGroups0.setGroups(new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups()));
121         String createdJson = standardCoder.encode(createdPdpGroups0);
122         assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", ""));
123
124         PdpGroups gotPdpGroups0 = new PdpGroups();
125         gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0"));
126
127         String gotJson = standardCoder.encode(gotPdpGroups0);
128
129         assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", ""));
130     }
131
132     @Test
133     public void testFilteredPdpGroupGet() throws Exception {
134         assertThatThrownBy(() -> {
135             new PdpProvider().getFilteredPdpGroups(null, null);
136         }).hasMessage("dao is marked @NonNull but is null");
137
138         assertThatThrownBy(() -> {
139             new PdpProvider().getFilteredPdpGroups(null, PdpGroupFilter.builder().build());
140         }).hasMessage("dao is marked @NonNull but is null");
141
142         assertThatThrownBy(() -> {
143             new PdpProvider().getFilteredPdpGroups(pfDao, null);
144         }).hasMessage("filter is marked @NonNull but is null");
145
146         String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroupsForFiltering.json");
147         PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class);
148
149         assertEquals(5, new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups()).size());
150
151         List<ToscaPolicyTypeIdentifier> policyTypeList = new ArrayList<>();
152         policyTypeList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3"));
153
154         List<ToscaPolicyIdentifier> policyList = new ArrayList<>();
155         policyList.add(new ToscaPolicyIdentifier("Policy0", "4.5.6"));
156
157         // @formatter:off
158         final PdpGroupFilter filter = PdpGroupFilter.builder()
159                 .groupState(PdpState.PASSIVE)
160                 .name("PdpGroup0")
161                 .matchPoliciesExactly(false)
162                 .matchPolicyTypesExactly(false)
163                 .pdpState(PdpState.PASSIVE)
164                 .pdpType("APEX")
165                 .policyTypeList(policyTypeList)
166                 .policyList(policyList)
167                 .build();
168         // @formatter:on
169         assertEquals(1, new PdpProvider().getFilteredPdpGroups(pfDao, filter).size());
170     }
171
172     @Test
173     public void testGroupsCreate() throws Exception {
174         assertThatThrownBy(() -> {
175             new PdpProvider().createPdpGroups(null, null);
176         }).hasMessage("dao is marked @NonNull but is null");
177
178         assertThatThrownBy(() -> {
179             new PdpProvider().createPdpGroups(null, new ArrayList<>());
180         }).hasMessage("dao is marked @NonNull but is null");
181
182         assertThatThrownBy(() -> {
183             new PdpProvider().createPdpGroups(pfDao, null);
184         }).hasMessage("pdpGroups is marked @NonNull but is null");
185
186         String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json");
187         PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class);
188
189         PdpGroups createdPdpGroups0 = new PdpGroups();
190         createdPdpGroups0.setGroups(new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups()));
191         String createdJson = standardCoder.encode(createdPdpGroups0);
192         assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", ""));
193
194         PdpGroups gotPdpGroups0 = new PdpGroups();
195         gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0"));
196
197         String gotJson = standardCoder.encode(gotPdpGroups0);
198         assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", ""));
199
200         pdpGroups0.getGroups().get(0).setPdpGroupState(null);
201         assertThatThrownBy(() -> {
202             new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups());
203         }).hasMessageContaining("INVALID:pdpGroupState may not be null");
204     }
205
206     @Test
207     public void testGroupsCreateNoPdp() throws Exception {
208         String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroupsNoPDPs.json");
209
210         PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class);
211
212         PdpGroups createdPdpGroups0 = new PdpGroups();
213         createdPdpGroups0.setGroups(new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups()));
214         assertNotEquals(pdpGroups0, createdPdpGroups0);
215         pdpGroups0.getGroups().get(0).getPdpSubgroups().get(0).setPdpInstances(new ArrayList<>());
216         String originalTweakedJson = standardCoder.encode(pdpGroups0);
217         String createdJson = standardCoder.encode(createdPdpGroups0);
218         assertEquals(originalTweakedJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", ""));
219
220         PdpGroups gotPdpGroups0 = new PdpGroups();
221         gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "TestPdpGroup"));
222
223         String gotJson = standardCoder.encode(gotPdpGroups0);
224         assertEquals(originalTweakedJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", ""));
225     }
226
227     @Test
228     public void testGroupsUpdate() throws Exception {
229         assertThatThrownBy(() -> {
230             new PdpProvider().updatePdpGroups(null, null);
231         }).hasMessage("dao is marked @NonNull but is null");
232
233         assertThatThrownBy(() -> {
234             new PdpProvider().updatePdpGroups(null, new ArrayList<>());
235         }).hasMessage("dao is marked @NonNull but is null");
236
237         assertThatThrownBy(() -> {
238             new PdpProvider().updatePdpGroups(pfDao, null);
239         }).hasMessage("pdpGroups is marked @NonNull but is null");
240
241         String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json");
242         PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class);
243
244         PdpGroups createdPdpGroups0 = new PdpGroups();
245         createdPdpGroups0.setGroups(new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups()));
246         String createdJson = standardCoder.encode(createdPdpGroups0);
247         assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", ""));
248
249         PdpGroups gotPdpGroups0 = new PdpGroups();
250         gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0"));
251
252         String gotJson = standardCoder.encode(gotPdpGroups0);
253         assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", ""));
254
255         String updateJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0Update.json");
256         PdpGroups updatePdpGroups0 = standardCoder.decode(updateJson, PdpGroups.class);
257
258         PdpGroups updatedPdpGroups0 = new PdpGroups();
259         updatedPdpGroups0.setGroups(new PdpProvider().updatePdpGroups(pfDao, updatePdpGroups0.getGroups()));
260
261         List<Pdp> beforePdpInstances = updatePdpGroups0.getGroups().get(0).getPdpSubgroups().get(0).getPdpInstances();
262         List<Pdp> afterPdpInstances = updatedPdpGroups0.getGroups().get(0).getPdpSubgroups().get(0).getPdpInstances();
263         assertTrue(beforePdpInstances.containsAll(afterPdpInstances));
264
265         pdpGroups0.getGroups().get(0).setPdpGroupState(null);
266         assertThatThrownBy(() -> {
267             new PdpProvider().updatePdpGroups(pfDao, pdpGroups0.getGroups());
268         }).hasMessageContaining("INVALID:pdpGroupState may not be null");
269     }
270
271     @Test
272     public void testPoliciesDelete() throws Exception {
273         assertThatThrownBy(() -> {
274             new PdpProvider().deletePdpGroup(null, null);
275         }).hasMessage("dao is marked @NonNull but is null");
276
277         assertThatThrownBy(() -> {
278             new PdpProvider().deletePdpGroup(null, "name");
279         }).hasMessage("dao is marked @NonNull but is null");
280
281         assertThatThrownBy(() -> {
282             new PdpProvider().deletePdpGroup(pfDao, null);
283         }).hasMessage("name is marked @NonNull but is null");
284
285         assertThatThrownBy(() -> {
286             new PdpProvider().deletePdpGroup(pfDao, "name");
287         }).hasMessage("delete of PDP group \"name:0.0.0\" failed, PDP group does not exist");
288
289         String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json");
290         PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class);
291
292         PdpGroups createdPdpGroups0 = new PdpGroups();
293         createdPdpGroups0.setGroups(new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups()));
294         String createdJson = standardCoder.encode(createdPdpGroups0);
295         assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", ""));
296
297         PdpGroups gotPdpGroups0 = new PdpGroups();
298         gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0"));
299
300         String gotJson = standardCoder.encode(gotPdpGroups0);
301         assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", ""));
302
303         PdpGroup deletedPdpGroup = new PdpProvider().deletePdpGroup(pfDao, "PdpGroup0");
304
305         assertEquals(createdPdpGroups0.getGroups().get(0), deletedPdpGroup);
306
307         assertEquals(0, new PdpProvider().getPdpGroups(pfDao, "PdpGroup0").size());
308
309         assertThatThrownBy(() -> {
310             new PdpProvider().deletePdpGroup(pfDao, "PdpGroup0");
311         }).hasMessage("delete of PDP group \"PdpGroup0:0.0.0\" failed, PDP group does not exist");
312     }
313
314     @Test
315     public void testPdpSubgroupUpdate() throws Exception {
316         assertThatThrownBy(() -> {
317             new PdpProvider().updatePdpSubGroup(null, null, null);
318         }).hasMessage("dao is marked @NonNull but is null");
319
320         assertThatThrownBy(() -> {
321             new PdpProvider().updatePdpSubGroup(null, null, new PdpSubGroup());
322         }).hasMessage("dao is marked @NonNull but is null");
323
324         assertThatThrownBy(() -> {
325             new PdpProvider().updatePdpSubGroup(null, "name", null);
326         }).hasMessage("dao is marked @NonNull but is null");
327
328         assertThatThrownBy(() -> {
329             new PdpProvider().updatePdpSubGroup(null, "name", new PdpSubGroup());
330         }).hasMessage("dao is marked @NonNull but is null");
331
332         assertThatThrownBy(() -> {
333             new PdpProvider().updatePdpSubGroup(pfDao, null, null);
334         }).hasMessage("pdpGroupName is marked @NonNull but is null");
335
336         assertThatThrownBy(() -> {
337             new PdpProvider().updatePdpSubGroup(pfDao, null, new PdpSubGroup());
338         }).hasMessage("pdpGroupName is marked @NonNull but is null");
339
340         assertThatThrownBy(() -> {
341             new PdpProvider().updatePdpSubGroup(pfDao, "name", null);
342         }).hasMessage("pdpSubGroup is marked @NonNull but is null");
343
344         assertThatThrownBy(() -> {
345             new PdpProvider().updatePdpSubGroup(pfDao, "name", new PdpSubGroup());
346         }).hasMessage("parameter \"localName\" is null");
347
348         String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json");
349         PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class);
350
351         PdpGroups createdPdpGroups0 = new PdpGroups();
352         createdPdpGroups0.setGroups(new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups()));
353         String createdJson = standardCoder.encode(createdPdpGroups0);
354         assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", ""));
355
356         PdpGroups gotPdpGroups0 = new PdpGroups();
357         gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0"));
358
359         String gotJson = standardCoder.encode(gotPdpGroups0);
360         assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", ""));
361
362         PdpSubGroup existingSubGroup = gotPdpGroups0.getGroups().get(0).getPdpSubgroups().get(0);
363         existingSubGroup.setCurrentInstanceCount(10);
364         existingSubGroup.setDesiredInstanceCount(10);
365         new PdpProvider().updatePdpSubGroup(pfDao, "PdpGroup0", existingSubGroup);
366
367         List<PdpGroup> afterUpdatePdpGroups = new PdpProvider().getPdpGroups(pfDao, "PdpGroup0");
368         assertEquals(10, afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getCurrentInstanceCount());
369         assertEquals(10, afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getDesiredInstanceCount());
370
371         existingSubGroup.setDesiredInstanceCount(-1);
372         assertThatThrownBy(() -> {
373             new PdpProvider().updatePdpSubGroup(pfDao, "PdpGroup0", existingSubGroup);
374         }).hasMessageContaining("INVALID:the desired instance count of a PDP sub group may not be negative");
375         existingSubGroup.setDesiredInstanceCount(10);
376     }
377
378     @Test
379     public void testPdpUpdate() throws Exception {
380         assertThatThrownBy(() -> {
381             new PdpProvider().updatePdp(null, null, null, null);
382         }).hasMessage("dao is marked @NonNull but is null");
383
384         assertThatThrownBy(() -> {
385             new PdpProvider().updatePdp(null, null, null, new Pdp());
386         }).hasMessage("dao is marked @NonNull but is null");
387
388         assertThatThrownBy(() -> {
389             new PdpProvider().updatePdp(null, null, "TYPE", null);
390         }).hasMessage("dao is marked @NonNull but is null");
391
392         assertThatThrownBy(() -> {
393             new PdpProvider().updatePdp(null, null, "TYPE", new Pdp());
394         }).hasMessage("dao is marked @NonNull but is null");
395
396         assertThatThrownBy(() -> {
397             new PdpProvider().updatePdp(null, "name", null, null);
398         }).hasMessage("dao is marked @NonNull but is null");
399
400         assertThatThrownBy(() -> {
401             new PdpProvider().updatePdp(null, "name", null, new Pdp());
402         }).hasMessage("dao is marked @NonNull but is null");
403
404         assertThatThrownBy(() -> {
405             new PdpProvider().updatePdp(null, "name", "TYPE", null);
406         }).hasMessage("dao is marked @NonNull but is null");
407
408         assertThatThrownBy(() -> {
409             new PdpProvider().updatePdp(null, "name", "TYPE", new Pdp());
410         }).hasMessage("dao is marked @NonNull but is null");
411
412         assertThatThrownBy(() -> {
413             new PdpProvider().updatePdp(pfDao, null, null, null);
414         }).hasMessage("pdpGroupName is marked @NonNull but is null");
415
416         assertThatThrownBy(() -> {
417             new PdpProvider().updatePdp(pfDao, null, null, new Pdp());
418         }).hasMessage("pdpGroupName is marked @NonNull but is null");
419
420         assertThatThrownBy(() -> {
421             new PdpProvider().updatePdp(pfDao, null, "TYPE", null);
422         }).hasMessage("pdpGroupName is marked @NonNull but is null");
423
424         assertThatThrownBy(() -> {
425             new PdpProvider().updatePdp(pfDao, null, "TYPE", new Pdp());
426         }).hasMessage("pdpGroupName is marked @NonNull but is null");
427
428         assertThatThrownBy(() -> {
429             new PdpProvider().updatePdp(pfDao, "name", null, null);
430         }).hasMessage("pdpSubGroup is marked @NonNull but is null");
431
432         assertThatThrownBy(() -> {
433             new PdpProvider().updatePdp(pfDao, "name", null, new Pdp());
434         }).hasMessage("pdpSubGroup is marked @NonNull but is null");
435
436         assertThatThrownBy(() -> {
437             new PdpProvider().updatePdp(pfDao, "name", "TYPE", null);
438         }).hasMessage("pdp is marked @NonNull but is null");
439
440         assertThatThrownBy(() -> {
441             new PdpProvider().updatePdp(pfDao, "name", "TYPE", new Pdp());
442         }).hasMessage("parameter \"localName\" is null");
443
444         String originalJson = ResourceUtils.getResourceAsString("testdata/PdpGroups0.json");
445         PdpGroups pdpGroups0 = standardCoder.decode(originalJson, PdpGroups.class);
446
447         PdpGroups createdPdpGroups0 = new PdpGroups();
448         createdPdpGroups0.setGroups(new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups()));
449         String createdJson = standardCoder.encode(createdPdpGroups0);
450         assertEquals(originalJson.replaceAll("\\s+", ""), createdJson.replaceAll("\\s+", ""));
451
452         PdpGroups gotPdpGroups0 = new PdpGroups();
453         gotPdpGroups0.setGroups(new PdpProvider().getPdpGroups(pfDao, "PdpGroup0"));
454
455         String gotJson = standardCoder.encode(gotPdpGroups0);
456         assertEquals(originalJson.replaceAll("\\s+", ""), gotJson.replaceAll("\\s+", ""));
457
458         Pdp existingPdp = gotPdpGroups0.getGroups().get(0).getPdpSubgroups().get(0).getPdpInstances().get(0);
459         existingPdp.setPdpState(PdpState.TEST);
460         existingPdp.setHealthy(PdpHealthStatus.TEST_IN_PROGRESS);
461         new PdpProvider().updatePdp(pfDao, "PdpGroup0", "APEX", existingPdp);
462
463         List<PdpGroup> afterUpdatePdpGroups = new PdpProvider().getPdpGroups(pfDao, "PdpGroup0");
464         assertEquals(PdpState.TEST,
465                 afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getPdpInstances().get(0).getPdpState());
466         assertEquals(PdpHealthStatus.TEST_IN_PROGRESS,
467                 afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getPdpInstances().get(0).getHealthy());
468
469         existingPdp.setMessage("");
470         assertThatThrownBy(() -> {
471             new PdpProvider().updatePdp(pfDao, "PdpGroup0", "APEX", existingPdp);
472         }).hasMessageContaining("INVALID:message may not be blank");
473         existingPdp.setMessage("A Message");
474     }
475
476     @Test
477     public void testGetPdpStatistics() throws PfModelException {
478         assertThatThrownBy(() -> {
479             new PdpProvider().getPdpStatistics(null, null);
480         }).hasMessage("dao is marked @NonNull but is null");
481
482         assertThatThrownBy(() -> {
483             new PdpProvider().getPdpStatistics(null, "name");
484         }).hasMessage("dao is marked @NonNull but is null");
485
486         assertEquals(0, new PdpProvider().getPdpStatistics(pfDao, "name").size());
487     }
488
489     @Test
490     public void testUpdatePdpStatistics() throws PfModelException {
491         assertThatThrownBy(() -> {
492             new PdpProvider().updatePdpStatistics(null, null, null, null, null);
493         }).hasMessage("dao is marked @NonNull but is null");
494
495         assertThatThrownBy(() -> {
496             new PdpProvider().updatePdpStatistics(null, null, null, null, new PdpStatistics());
497         }).hasMessage("dao is marked @NonNull but is null");
498
499         assertThatThrownBy(() -> {
500             new PdpProvider().updatePdpStatistics(null, null, null, "inst", null);
501         }).hasMessage("dao is marked @NonNull but is null");
502
503         assertThatThrownBy(() -> {
504             new PdpProvider().updatePdpStatistics(null, null, null, "inst", new PdpStatistics());
505         }).hasMessage("dao is marked @NonNull but is null");
506
507         assertThatThrownBy(() -> {
508             new PdpProvider().updatePdpStatistics(null, null, "TYPE", null, null);
509         }).hasMessage("dao is marked @NonNull but is null");
510
511         assertThatThrownBy(() -> {
512             new PdpProvider().updatePdpStatistics(null, null, "TYPE", null, new PdpStatistics());
513         }).hasMessage("dao is marked @NonNull but is null");
514
515         assertThatThrownBy(() -> {
516             new PdpProvider().updatePdpStatistics(null, null, "TYPE", "inst", null);
517         }).hasMessage("dao is marked @NonNull but is null");
518
519         assertThatThrownBy(() -> {
520             new PdpProvider().updatePdpStatistics(null, null, "TYPE", "inst", new PdpStatistics());
521         }).hasMessage("dao is marked @NonNull but is null");
522
523         assertThatThrownBy(() -> {
524             new PdpProvider().updatePdpStatistics(null, "name", null, null, null);
525         }).hasMessage("dao is marked @NonNull but is null");
526
527         assertThatThrownBy(() -> {
528             new PdpProvider().updatePdpStatistics(null, "name", null, null, new PdpStatistics());
529         }).hasMessage("dao is marked @NonNull but is null");
530
531         assertThatThrownBy(() -> {
532             new PdpProvider().updatePdpStatistics(null, "name", null, "inst", null);
533         }).hasMessage("dao is marked @NonNull but is null");
534
535         assertThatThrownBy(() -> {
536             new PdpProvider().updatePdpStatistics(null, "name", null, "inst", new PdpStatistics());
537         }).hasMessage("dao is marked @NonNull but is null");
538
539         assertThatThrownBy(() -> {
540             new PdpProvider().updatePdpStatistics(null, "name", "TYPE", null, null);
541         }).hasMessage("dao is marked @NonNull but is null");
542
543         assertThatThrownBy(() -> {
544             new PdpProvider().updatePdpStatistics(null, "name", "TYPE", null, new PdpStatistics());
545         }).hasMessage("dao is marked @NonNull but is null");
546
547         assertThatThrownBy(() -> {
548             new PdpProvider().updatePdpStatistics(null, "name", "TYPE", "inst", null);
549         }).hasMessage("dao is marked @NonNull but is null");
550
551         assertThatThrownBy(() -> {
552             new PdpProvider().updatePdpStatistics(null, "name", "TYPE", "inst", new PdpStatistics());
553         }).hasMessage("dao is marked @NonNull but is null");
554
555         assertThatThrownBy(() -> {
556             new PdpProvider().updatePdpStatistics(pfDao, null, null, null, null);
557         }).hasMessage("pdpGroupName is marked @NonNull but is null");
558
559         assertThatThrownBy(() -> {
560             new PdpProvider().updatePdpStatistics(pfDao, null, null, null, new PdpStatistics());
561         }).hasMessage("pdpGroupName is marked @NonNull but is null");
562
563         assertThatThrownBy(() -> {
564             new PdpProvider().updatePdpStatistics(pfDao, null, null, "inst", null);
565         }).hasMessage("pdpGroupName is marked @NonNull but is null");
566
567         assertThatThrownBy(() -> {
568             new PdpProvider().updatePdpStatistics(pfDao, null, null, "inst", new PdpStatistics());
569         }).hasMessage("pdpGroupName is marked @NonNull but is null");
570
571         assertThatThrownBy(() -> {
572             new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", null, null);
573         }).hasMessage("pdpGroupName is marked @NonNull but is null");
574
575         assertThatThrownBy(() -> {
576             new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", null, new PdpStatistics());
577         }).hasMessage("pdpGroupName is marked @NonNull but is null");
578
579         assertThatThrownBy(() -> {
580             new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", "inst", null);
581         }).hasMessage("pdpGroupName is marked @NonNull but is null");
582
583         assertThatThrownBy(() -> {
584             new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", "inst", new PdpStatistics());
585         }).hasMessage("pdpGroupName is marked @NonNull but is null");
586
587         assertThatThrownBy(() -> {
588             new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, null);
589         }).hasMessage("pdpType is marked @NonNull but is null");
590
591         assertThatThrownBy(() -> {
592             new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, new PdpStatistics());
593         }).hasMessage("pdpType is marked @NonNull but is null");
594
595         assertThatThrownBy(() -> {
596             new PdpProvider().updatePdpStatistics(pfDao, "name", null, "inst", null);
597         }).hasMessage("pdpType is marked @NonNull but is null");
598
599         assertThatThrownBy(() -> {
600             new PdpProvider().updatePdpStatistics(pfDao, "name", null, "inst", new PdpStatistics());
601         }).hasMessage("pdpType is marked @NonNull but is null");
602
603         assertThatThrownBy(() -> {
604             new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", null, null);
605         }).hasMessage("pdpInstanceId is marked @NonNull but is null");
606
607         assertThatThrownBy(() -> {
608             new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", null, new PdpStatistics());
609         }).hasMessage("pdpInstanceId is marked @NonNull but is null");
610
611         assertThatThrownBy(() -> {
612             new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", "inst", null);
613         }).hasMessage("pdpStatistics is marked @NonNull but is null");
614
615         new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", "inst", new PdpStatistics());
616     }
617 }