fd566a52fd43b66915fa865e4b3ee5f0750f62b5
[policy/models.git] / models-provider / src / test / java / org / onap / policy / models / provider / impl / DatabasePolicyModelsProviderTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019-2020 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.provider.impl;
23
24 import static org.assertj.core.api.Assertions.assertThatThrownBy;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
28 import static org.junit.Assert.fail;
29
30 import java.util.ArrayList;
31 import java.util.Base64;
32 import java.util.Date;
33 import java.util.List;
34 import org.junit.Before;
35 import org.junit.Test;
36 import org.onap.policy.models.pdp.concepts.Pdp;
37 import org.onap.policy.models.pdp.concepts.PdpGroup;
38 import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
39 import org.onap.policy.models.pdp.concepts.PdpStatistics;
40 import org.onap.policy.models.pdp.concepts.PdpSubGroup;
41 import org.onap.policy.models.pdp.enums.PdpHealthStatus;
42 import org.onap.policy.models.pdp.enums.PdpState;
43 import org.onap.policy.models.provider.PolicyModelsProvider;
44 import org.onap.policy.models.provider.PolicyModelsProviderFactory;
45 import org.onap.policy.models.provider.PolicyModelsProviderParameters;
46 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
47 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
48 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
49 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
50 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
51 import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
52 import org.slf4j.Logger;
53 import org.slf4j.LoggerFactory;
54
55 /**
56  * Test the database models provider implementation.
57  *
58  * @author Liam Fallon (liam.fallon@est.tech)
59  */
60 public class DatabasePolicyModelsProviderTest {
61     private static final String NAME = "name";
62
63     private static final String TEMPLATE_IS_NULL = "^serviceTemplate is marked .*on.*ull but is null$";
64
65     private static final String POLICY_ID_IS_NULL = "^policyId is marked .*on.*ull but is null$";
66
67     private static final String SUBGROUP_IS_NULL = "^pdpSubGroup is marked .*on.*ull but is null$";
68
69     private static final String GROUP_IS_NULL = "^pdpGroupName is marked .*on.*ull but is null$";
70
71     private static final String NAME_IS_NULL = "^name is marked .*on.*ull but is null$";
72
73     private static final String FILTER_IS_NULL = "^filter is marked .*on.*ull but is null$";
74
75     private static final String POLICY_ID = "policy_id";
76
77     private static final String GROUP = "group";
78
79     private static final String VERSION_100 = "1.0.0";
80
81     private static final Date TIMESTAMP = new Date();
82
83     private static final String ORDER = "DESC";
84
85     private static final Logger LOGGER = LoggerFactory.getLogger(DatabasePolicyModelsProviderTest.class);
86
87     PolicyModelsProviderParameters parameters;
88
89     /**
90      * Initialize parameters.
91      */
92     @Before
93     public void setupParameters() {
94         parameters = new PolicyModelsProviderParameters();
95         parameters.setDatabaseDriver("org.h2.Driver");
96         parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
97         parameters.setDatabaseUser("policy");
98         parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
99         parameters.setPersistenceUnit("ToscaConceptTest");
100     }
101
102     @Test
103     public void testInitAndClose() throws Exception {
104         assertThatThrownBy(() -> {
105             new DatabasePolicyModelsProviderImpl(null);
106         }).hasMessageMatching("^parameters is marked .*on.*ull but is null$");
107
108         PolicyModelsProvider databaseProvider =
109                 new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
110
111         parameters.setDatabaseUrl("jdbc://www.acmecorp.nonexist");
112
113         databaseProvider.close();
114         databaseProvider.init();
115
116         databaseProvider.close();
117
118         parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
119
120         parameters.setPersistenceUnit("WileECoyote");
121
122         assertThatThrownBy(databaseProvider::init).hasMessageContaining("could not create Data Access Object (DAO)");
123
124         parameters.setPersistenceUnit("ToscaConceptTest");
125
126         databaseProvider.init();
127         databaseProvider.close();
128
129         assertThatThrownBy(() -> {
130             databaseProvider.init();
131             databaseProvider.init();
132         }).hasMessage("provider is already initialized");
133
134         databaseProvider.close();
135
136         databaseProvider.close();
137     }
138
139     @Test
140     public void testProviderMethodsNull() throws Exception {
141
142         try (PolicyModelsProvider databaseProvider =
143                 new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters)) {
144
145             assertThatThrownBy(() -> {
146                 databaseProvider.getFilteredPolicyTypes(null);
147             }).hasMessageMatching(FILTER_IS_NULL);
148
149             assertThatThrownBy(() -> {
150                 databaseProvider.getFilteredPolicyTypeList(null);
151             }).hasMessageMatching(FILTER_IS_NULL);
152
153             assertThatThrownBy(() -> {
154                 databaseProvider.createPolicyTypes(null);
155             }).hasMessageMatching(TEMPLATE_IS_NULL);
156
157             assertThatThrownBy(() -> {
158                 databaseProvider.updatePolicyTypes(null);
159             }).hasMessageMatching(TEMPLATE_IS_NULL);
160
161             assertThatThrownBy(() -> {
162                 databaseProvider.deletePolicyType(null, null);
163             }).hasMessageMatching(NAME_IS_NULL);
164
165             assertThatThrownBy(() -> {
166                 databaseProvider.deletePolicyType("aaa", null);
167             }).hasMessageMatching("^version is marked .*on.*ull but is null$");
168
169             assertThatThrownBy(() -> {
170                 databaseProvider.deletePolicyType(null, "aaa");
171             }).hasMessageMatching(NAME_IS_NULL);
172
173             assertThatThrownBy(() -> {
174                 databaseProvider.getFilteredPolicies(null);
175             }).hasMessageMatching(FILTER_IS_NULL);
176
177             assertThatThrownBy(() -> {
178                 databaseProvider.getFilteredPolicyList(null);
179             }).hasMessageMatching(FILTER_IS_NULL);
180
181             assertThatThrownBy(() -> {
182                 databaseProvider.createPolicies(null);
183             }).hasMessageMatching(TEMPLATE_IS_NULL);
184
185             assertThatThrownBy(() -> {
186                 databaseProvider.updatePolicies(null);
187             }).hasMessageMatching(TEMPLATE_IS_NULL);
188
189             assertThatThrownBy(() -> {
190                 databaseProvider.deletePolicy(null, null);
191             }).hasMessageMatching(NAME_IS_NULL);
192
193             assertThatThrownBy(() -> {
194                 databaseProvider.deletePolicy(null, "aaa");
195             }).hasMessageMatching(NAME_IS_NULL);
196
197             assertThatThrownBy(() -> {
198                 databaseProvider.deletePolicy("aaa", null);
199             }).hasMessageMatching("^version is marked .*on.*ull but is null$");
200
201             assertThatThrownBy(() -> {
202                 databaseProvider.getOperationalPolicy(null, null);
203             }).hasMessageMatching(POLICY_ID_IS_NULL);
204
205             assertThatThrownBy(() -> {
206                 databaseProvider.getOperationalPolicy(null, "");
207             }).hasMessageMatching(POLICY_ID_IS_NULL);
208
209             assertThatThrownBy(() -> {
210                 databaseProvider.getOperationalPolicy("", null);
211             }).hasMessage("no policy found for policy: :null");
212
213             assertThatThrownBy(() -> {
214                 databaseProvider.createOperationalPolicy(null);
215             }).hasMessageMatching("^legacyOperationalPolicy is marked .*on.*ull but is null$");
216
217             assertThatThrownBy(() -> {
218                 databaseProvider.updateOperationalPolicy(null);
219             }).hasMessageMatching("^legacyOperationalPolicy is marked .*on.*ull but is null$");
220
221             assertThatThrownBy(() -> {
222                 databaseProvider.deleteOperationalPolicy(null, null);
223             }).hasMessageMatching(POLICY_ID_IS_NULL);
224
225             assertThatThrownBy(() -> {
226                 databaseProvider.deleteOperationalPolicy(null, "");
227             }).hasMessageMatching(POLICY_ID_IS_NULL);
228
229             assertThatThrownBy(() -> {
230                 databaseProvider.deleteOperationalPolicy("", null);
231             }).hasMessageMatching("^policyVersion is marked .*on.*ull but is null$");
232
233             assertThatThrownBy(() -> {
234                 databaseProvider.getGuardPolicy(null, null);
235             }).hasMessageMatching(POLICY_ID_IS_NULL);
236
237             assertThatThrownBy(() -> {
238                 databaseProvider.getGuardPolicy(null, "");
239             }).hasMessageMatching(POLICY_ID_IS_NULL);
240
241             assertThatThrownBy(() -> {
242                 databaseProvider.getGuardPolicy("", null);
243             }).hasMessage("no policy found for policy: :null");
244
245             assertThatThrownBy(() -> {
246                 databaseProvider.createGuardPolicy(null);
247             }).hasMessageMatching("^legacyGuardPolicy is marked .*on.*ull but is null$");
248
249             assertThatThrownBy(() -> {
250                 databaseProvider.updateGuardPolicy(null);
251             }).hasMessageMatching("^legacyGuardPolicy is marked .*on.*ull but is null$");
252
253             assertThatThrownBy(() -> {
254                 databaseProvider.deleteGuardPolicy(null, null);
255             }).hasMessageMatching(POLICY_ID_IS_NULL);
256
257             assertThatThrownBy(() -> {
258                 databaseProvider.deleteGuardPolicy(null, "");
259             }).hasMessageMatching(POLICY_ID_IS_NULL);
260
261             assertThatThrownBy(() -> {
262                 databaseProvider.deleteGuardPolicy("", null);
263             }).hasMessageMatching("^policyVersion is marked .*on.*ull but is null$");
264
265             assertThatThrownBy(() -> {
266                 databaseProvider.getFilteredPdpGroups(null);
267             }).hasMessageMatching(FILTER_IS_NULL);
268
269             assertThatThrownBy(() -> {
270                 databaseProvider.createPdpGroups(null);
271             }).hasMessageMatching("^pdpGroups is marked .*on.*ull but is null$");
272
273             assertThatThrownBy(() -> {
274                 databaseProvider.updatePdpGroups(null);
275             }).hasMessageMatching("^pdpGroups is marked .*on.*ull but is null$");
276
277             assertThatThrownBy(() -> {
278                 databaseProvider.updatePdpSubGroup(null, null);
279             }).hasMessageMatching(GROUP_IS_NULL);
280
281             assertThatThrownBy(() -> {
282                 databaseProvider.updatePdpSubGroup(null, new PdpSubGroup());
283             }).hasMessageMatching(GROUP_IS_NULL);
284
285             assertThatThrownBy(() -> {
286                 databaseProvider.updatePdpSubGroup(NAME, null);
287             }).hasMessageMatching(SUBGROUP_IS_NULL);
288
289             assertThatThrownBy(() -> {
290                 databaseProvider.updatePdpSubGroup(NAME, new PdpSubGroup());
291             }).hasMessage("parameter \"localName\" is null");
292
293             assertThatThrownBy(() -> {
294                 databaseProvider.updatePdp(null, null, null);
295             }).hasMessageMatching(GROUP_IS_NULL);
296
297             assertThatThrownBy(() -> {
298                 databaseProvider.updatePdp(null, null, new Pdp());
299             }).hasMessageMatching(GROUP_IS_NULL);
300
301             assertThatThrownBy(() -> {
302                 databaseProvider.updatePdp(null, "sub", null);
303             }).hasMessageMatching(GROUP_IS_NULL);
304
305             assertThatThrownBy(() -> {
306                 databaseProvider.updatePdp(null, "sub", new Pdp());
307             }).hasMessageMatching(GROUP_IS_NULL);
308
309             assertThatThrownBy(() -> {
310                 databaseProvider.updatePdp(NAME, null, null);
311             }).hasMessageMatching(SUBGROUP_IS_NULL);
312
313             assertThatThrownBy(() -> {
314                 databaseProvider.updatePdp(NAME, null, new Pdp());
315             }).hasMessageMatching(SUBGROUP_IS_NULL);
316
317             assertThatThrownBy(() -> {
318                 databaseProvider.updatePdp(NAME, "sub", null);
319             }).hasMessageMatching("^pdp is marked .*on.*ull but is null$");
320
321             assertThatThrownBy(() -> {
322                 databaseProvider.updatePdp(NAME, "sub", new Pdp());
323             }).hasMessage("parameter \"localName\" is null");
324
325             assertThatThrownBy(() -> {
326                 databaseProvider.deletePdpGroup(null);
327             }).hasMessageMatching(NAME_IS_NULL);
328
329             assertThatThrownBy(() -> {
330                 databaseProvider.getFilteredPdpStatistics(NAME, null, "sub", TIMESTAMP, TIMESTAMP, ORDER, 0);
331             }).hasMessageMatching(GROUP_IS_NULL);
332
333             assertThatThrownBy(() -> {
334                 databaseProvider.createPdpStatistics(null);
335             }).hasMessageMatching("^pdpStatisticsList is marked .*on.*ull but is null$");
336
337             assertThatThrownBy(() -> {
338                 databaseProvider.updatePdpStatistics(null);
339             }).hasMessageMatching("^pdpStatisticsList is marked .*on.*ull but is null$");
340
341             assertThatThrownBy(() -> {
342                 databaseProvider.deletePdpStatistics(null, TIMESTAMP);
343             }).hasMessageMatching(NAME_IS_NULL);
344
345         }
346     }
347
348     @Test
349     public void testProviderMethodsNotInit() throws Exception {
350         PolicyModelsProvider databaseProvider =
351                 new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
352
353         databaseProvider.close();
354
355         assertThatThrownBy(() -> {
356             databaseProvider.getPolicyTypes(NAME, "version");
357         }).hasMessage("policy models provider is not initilaized");
358     }
359
360     @Test
361     public void testProviderMethods() {
362         try (PolicyModelsProvider databaseProvider =
363                 new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters)) {
364
365             assertTrue(databaseProvider.getPolicyTypes(NAME, VERSION_100).getPolicyTypes().isEmpty());
366             assertTrue(databaseProvider.getPolicyTypeList(NAME, VERSION_100).isEmpty());
367             assertEquals(0, databaseProvider.getFilteredPolicyTypes(ToscaPolicyTypeFilter.builder().build())
368                     .getPolicyTypes().size());
369             assertEquals(0, databaseProvider.getFilteredPolicyTypeList(ToscaPolicyTypeFilter.builder().build()).size());
370
371             assertThatThrownBy(() -> {
372                 databaseProvider.createPolicyTypes(new ToscaServiceTemplate());
373             }).hasMessage("no policy types specified on service template");
374
375             assertThatThrownBy(() -> {
376                 databaseProvider.updatePolicyTypes(new ToscaServiceTemplate());
377             }).hasMessage("no policy types specified on service template");
378
379             assertTrue(databaseProvider.deletePolicyType(NAME, VERSION_100).getPolicyTypes().isEmpty());
380
381             assertTrue(databaseProvider.deletePolicyType(NAME, VERSION_100).getPolicyTypes().isEmpty());
382
383             assertTrue(
384                     databaseProvider.getPolicies(NAME, VERSION_100).getToscaTopologyTemplate().getPolicies().isEmpty());
385             assertTrue(databaseProvider.getPolicyList(NAME, VERSION_100).isEmpty());
386             assertEquals(0, databaseProvider.getFilteredPolicies(ToscaPolicyFilter.builder().build())
387                     .getToscaTopologyTemplate().getPolicies().size());
388             assertEquals(0, databaseProvider.getFilteredPolicyList(ToscaPolicyFilter.builder().build()).size());
389
390             assertThatThrownBy(() -> {
391                 databaseProvider.createPolicies(new ToscaServiceTemplate());
392             }).hasMessage("topology template not specified on service template");
393
394             assertThatThrownBy(() -> {
395                 databaseProvider.updatePolicies(new ToscaServiceTemplate());
396             }).hasMessage("topology template not specified on service template");
397
398             assertTrue(databaseProvider.deletePolicy("Policy", "0.0.0").getToscaTopologyTemplate().getPolicies()
399                     .isEmpty());
400
401             assertThatThrownBy(() -> {
402                 databaseProvider.getOperationalPolicy(POLICY_ID, null);
403             }).hasMessage("no policy found for policy: policy_id:null");
404
405             assertThatThrownBy(() -> {
406                 databaseProvider.getOperationalPolicy(POLICY_ID, "10");
407             }).hasMessage("no policy found for policy: policy_id:10");
408
409             assertThatThrownBy(() -> {
410                 databaseProvider.createOperationalPolicy(new LegacyOperationalPolicy());
411             }).hasMessageMatching(NAME_IS_NULL);
412
413             assertThatThrownBy(() -> {
414                 databaseProvider.updateOperationalPolicy(new LegacyOperationalPolicy());
415             }).hasMessageMatching(NAME_IS_NULL);
416
417             assertThatThrownBy(() -> {
418                 databaseProvider.deleteOperationalPolicy(POLICY_ID, "55");
419             }).hasMessage("no policy found for policy: policy_id:55");
420
421             assertThatThrownBy(() -> {
422                 databaseProvider.getGuardPolicy(POLICY_ID, null);
423             }).hasMessage("no policy found for policy: policy_id:null");
424
425             assertThatThrownBy(() -> {
426                 databaseProvider.getGuardPolicy(POLICY_ID, "6");
427             }).hasMessage("no policy found for policy: policy_id:6");
428
429             assertThatThrownBy(() -> {
430                 databaseProvider.createGuardPolicy(new LegacyGuardPolicyInput());
431             }).hasMessage("policy type for guard policy \"null\" unknown");
432
433             assertThatThrownBy(() -> {
434                 databaseProvider.updateGuardPolicy(new LegacyGuardPolicyInput());
435             }).hasMessage("policy type for guard policy \"null\" unknown");
436
437             assertThatThrownBy(() -> {
438                 databaseProvider.deleteGuardPolicy(POLICY_ID, "33");
439             }).hasMessage("no policy found for policy: policy_id:33");
440
441             assertEquals(0, databaseProvider.getPdpGroups(NAME).size());
442             assertEquals(0, databaseProvider.getFilteredPdpGroups(PdpGroupFilter.builder().build()).size());
443
444             assertNotNull(databaseProvider.createPdpGroups(new ArrayList<>()));
445             assertNotNull(databaseProvider.updatePdpGroups(new ArrayList<>()));
446
447             PdpGroup pdpGroup = new PdpGroup();
448             pdpGroup.setName(GROUP);
449             pdpGroup.setVersion("1.2.3");
450             pdpGroup.setPdpGroupState(PdpState.ACTIVE);
451             pdpGroup.setPdpSubgroups(new ArrayList<>());
452             List<PdpGroup> groupList = new ArrayList<>();
453             groupList.add(pdpGroup);
454
455             PdpSubGroup pdpSubGroup = new PdpSubGroup();
456             pdpSubGroup.setPdpType("type");
457             pdpSubGroup.setDesiredInstanceCount(123);
458             pdpSubGroup.setSupportedPolicyTypes(new ArrayList<>());
459             pdpSubGroup.getSupportedPolicyTypes().add(new ToscaPolicyTypeIdentifier("type", "7.8.9"));
460             pdpGroup.getPdpSubgroups().add(pdpSubGroup);
461
462             Pdp pdp = new Pdp();
463             pdp.setInstanceId("type-0");
464             pdp.setMessage("Hello");
465             pdp.setPdpState(PdpState.ACTIVE);
466             pdp.setHealthy(PdpHealthStatus.UNKNOWN);
467             pdpSubGroup.setPdpInstances(new ArrayList<>());
468             pdpSubGroup.getPdpInstances().add(pdp);
469
470             PdpStatistics pdpStatistics = new PdpStatistics();
471             pdpStatistics.setPdpInstanceId(NAME);
472             pdpStatistics.setTimeStamp(new Date());
473             pdpStatistics.setPdpGroupName(GROUP);
474             pdpStatistics.setPdpSubGroupName("type");
475             ArrayList<PdpStatistics> statisticsArrayList = new ArrayList<>();
476             statisticsArrayList.add(pdpStatistics);
477
478             assertEquals(123, databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0)
479                     .getDesiredInstanceCount());
480             assertEquals(1, databaseProvider.getPdpGroups(GROUP).size());
481
482             pdpSubGroup.setDesiredInstanceCount(234);
483             databaseProvider.updatePdpSubGroup(GROUP, pdpSubGroup);
484             assertEquals(234,
485                     databaseProvider.getPdpGroups(GROUP).get(0).getPdpSubgroups().get(0).getDesiredInstanceCount());
486
487             assertEquals("Hello", databaseProvider.getPdpGroups(GROUP).get(0).getPdpSubgroups().get(0).getPdpInstances()
488                     .get(0).getMessage());
489             pdp.setMessage("Howdy");
490             databaseProvider.updatePdp(GROUP, "type", pdp);
491             assertEquals("Howdy", databaseProvider.getPdpGroups(GROUP).get(0).getPdpSubgroups().get(0).getPdpInstances()
492                     .get(0).getMessage());
493
494             assertThatThrownBy(() -> {
495                 databaseProvider.deletePdpGroup(NAME);
496             }).hasMessage("delete of PDP group \"name:0.0.0\" failed, PDP group does not exist");
497
498             assertEquals(pdpGroup.getName(), databaseProvider.deletePdpGroup(GROUP).getName());
499
500             assertEquals(0, databaseProvider.getPdpStatistics(null, null).size());
501             assertEquals(1, databaseProvider.createPdpStatistics(statisticsArrayList).size());
502             assertEquals(1, databaseProvider.updatePdpStatistics(statisticsArrayList).size());
503
504             assertEquals(NAME, databaseProvider.getPdpStatistics(null, null).get(0).getPdpInstanceId());
505             assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(null, GROUP, null, null, null, ORDER, 0).get(0)
506                     .getPdpInstanceId());
507             assertEquals(0,
508                     databaseProvider.getFilteredPdpStatistics(null, GROUP, null, new Date(), null, ORDER, 0).size());
509             assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(null, GROUP, null, null, new Date(), ORDER, 0)
510                     .get(0).getPdpInstanceId());
511             assertEquals(0, databaseProvider
512                     .getFilteredPdpStatistics(null, GROUP, null, new Date(), new Date(), ORDER, 0).size());
513
514             assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, null, null, null, ORDER, 0).get(0)
515                     .getPdpInstanceId());
516             assertEquals(0, databaseProvider
517                     .getFilteredPdpStatistics(NAME, GROUP, null, new Date(), new Date(), ORDER, 0).size());
518
519             assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", null, null, ORDER, 0)
520                     .get(0).getPdpInstanceId());
521             assertEquals(0, databaseProvider
522                     .getFilteredPdpStatistics(NAME, GROUP, "type", new Date(), new Date(), ORDER, 0).size());
523
524             assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", null, null, ORDER, 1)
525                     .get(0).getPdpInstanceId());
526             assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", null, null, ORDER, 5)
527                     .get(0).getPdpInstanceId());
528             assertEquals(0, databaseProvider
529                     .getFilteredPdpStatistics(NAME, GROUP, "type", new Date(), new Date(), ORDER, 5).size());
530
531             assertEquals(NAME, databaseProvider.deletePdpStatistics(NAME, null).get(0).getPdpInstanceId());
532             assertEquals(0, databaseProvider.getPdpStatistics(null, null).size());
533         } catch (Exception exc) {
534             LOGGER.warn("test should not throw an exception", exc);
535             fail("test should not throw an exception");
536         }
537     }
538 }