433196421ced15c0ccf0b15b159c8771b8c4fbdc
[policy/models.git] / models-dao / src / test / java / org / onap / policy / models / dao / EntityTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019-2020 Nordix Foundation.
4  *  Modifications Copyright (C) 2019-2020 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.dao;
23
24 import static org.assertj.core.api.Assertions.assertThatCode;
25 import static org.assertj.core.api.Assertions.assertThatThrownBy;
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertNotNull;
28 import static org.junit.Assert.assertNull;
29 import static org.junit.Assert.assertTrue;
30
31 import java.util.ArrayList;
32 import java.util.Date;
33 import java.util.HashMap;
34 import java.util.List;
35 import java.util.Map;
36 import java.util.Properties;
37 import java.util.Set;
38 import java.util.TreeSet;
39 import java.util.UUID;
40 import org.eclipse.persistence.config.PersistenceUnitProperties;
41 import org.junit.Test;
42 import org.onap.policy.models.base.PfConceptKey;
43 import org.onap.policy.models.base.PfModelException;
44 import org.onap.policy.models.base.PfReferenceKey;
45 import org.onap.policy.models.base.PfTimestampKey;
46 import org.onap.policy.models.dao.impl.DefaultPfDao;
47
48 /**
49  * JUnit test class.
50  */
51 public class EntityTest {
52     private static final String DESCRIPTION2 = "key description 2";
53     private static final String DESCRIPTION1 = "key description 1";
54     private static final String DESCRIPTION0 = "key description 0";
55     private static final String ENTITY0 = "Entity0";
56     private static final String UUID2 = "00000000-0000-0000-0000-000000000002";
57     private static final String UUID1 = "00000000-0000-0000-0000-000000000001";
58     private static final String UUID0 = "00000000-0000-0000-0000-000000000000";
59     private static final String VERSION003 = "0.0.3";
60     private static final String VERSION002 = "0.0.2";
61     private static final String VERSION001 = "0.0.1";
62     private static final Date TIMESTAMP0 = new Date();
63     private static final Date TIMESTAMP1 = new Date();
64     private static final Date TIMESTAMP2 = new Date();
65     private PfDao pfDao;
66
67     @Test
68     public void testEntityTestSanity() throws PfModelException {
69         final DaoParameters daoParameters = new DaoParameters();
70
71         Properties jdbcProperties = new Properties();
72         // @formatter:off
73         jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER,   "org.h2.Driver");
74         jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL,      "jdbc:h2:mem:testdb");
75         jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER,     "sa");
76         jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "");
77         // @formatter:on
78
79         daoParameters.setJdbcProperties(jdbcProperties);
80
81         pfDao = new PfDaoFactory().createPfDao(daoParameters);
82
83         assertThatThrownBy(() -> pfDao.init(null)).hasMessage("Policy Framework persistence unit parameter not set");
84
85         assertThatThrownBy(() -> pfDao.init(daoParameters))
86                         .hasMessage("Policy Framework persistence unit parameter not set");
87
88         daoParameters.setPluginClass("somewhere.over.the.rainbow");
89         daoParameters.setPersistenceUnit("Dorothy");
90
91         assertThatThrownBy(() -> pfDao.init(daoParameters))
92                         .hasMessage("Creation of Policy Framework persistence unit \"Dorothy\" failed");
93
94         assertThatThrownBy(() -> pfDao.create(new PfConceptKey()))
95                         .hasMessage("Policy Framework DAO has not been initialized");
96
97         pfDao.close();
98     }
99
100     @Test
101     public void testEntityTestAllOpsJpa() throws PfModelException {
102
103         final DaoParameters daoParameters = new DaoParameters();
104         daoParameters.setPluginClass(DefaultPfDao.class.getName());
105         daoParameters.setPersistenceUnit("DaoTest");
106
107         Properties jdbcProperties = new Properties();
108         jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
109         jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:testdb");
110         jdbcProperties.setProperty("javax.persistence.jdbc.user", "sa");
111         jdbcProperties.setProperty("javax.persistence.jdbc.password", "");
112
113         daoParameters.setJdbcProperties(jdbcProperties);
114
115         pfDao = new PfDaoFactory().createPfDao(daoParameters);
116         pfDao.init(daoParameters);
117
118         testAllOps();
119
120         testVersionOps();
121
122         testgetFilteredOps();
123
124         pfDao.close();
125     }
126
127     @Test
128     public void testEntityTestBadVals() throws PfModelException {
129         final DaoParameters daoParameters = new DaoParameters();
130         daoParameters.setPluginClass(DefaultPfDao.class.getName());
131         daoParameters.setPersistenceUnit("DaoTest");
132
133         pfDao = new PfDaoFactory().createPfDao(daoParameters);
134         pfDao.init(daoParameters);
135
136         final PfConceptKey nullKey = null;
137         final PfReferenceKey nullRefKey = null;
138         final PfTimestampKey nullTimeKey = null;
139         final List<PfConceptKey> nullKeyList = null;
140         final List<PfConceptKey> emptyKeyList = new ArrayList<>();
141         final List<PfReferenceKey> nullRKeyList = null;
142         final List<PfReferenceKey> emptyRKeyList = new ArrayList<>();
143
144         pfDao.create(nullKey);
145         pfDao.createCollection(nullKeyList);
146         pfDao.createCollection(emptyKeyList);
147
148         pfDao.delete(nullKey);
149         pfDao.deleteCollection(nullKeyList);
150         pfDao.deleteCollection(emptyKeyList);
151         pfDao.delete(PfConceptKey.class, nullKey);
152         pfDao.delete(PfReferenceKey.class, nullRefKey);
153         pfDao.delete(PfTimestampKey.class, nullTimeKey);
154         pfDao.deleteByConceptKey(PfConceptKey.class, nullKeyList);
155         pfDao.deleteByConceptKey(PfConceptKey.class, emptyKeyList);
156         pfDao.deleteByReferenceKey(PfReferenceKey.class, nullRKeyList);
157         pfDao.deleteByReferenceKey(PfReferenceKey.class, emptyRKeyList);
158
159         pfDao.get(null, nullKey);
160         pfDao.get(null, nullRefKey);
161         pfDao.get(null, nullTimeKey);
162         pfDao.getAll(null);
163         pfDao.getAll(null, nullKey);
164         pfDao.getConcept(null, nullKey);
165         pfDao.getConcept(PfConceptKey.class, nullKey);
166         pfDao.getConcept(null, nullRefKey);
167         pfDao.getConcept(PfReferenceKey.class, nullRefKey);
168         pfDao.size(null);
169
170         assertThatCode(() -> pfDao.close()).doesNotThrowAnyException();
171     }
172
173     private void testAllOps() {
174         final PfConceptKey aKey0 = new PfConceptKey("A-KEY0", VERSION001);
175         final PfConceptKey aKey1 = new PfConceptKey("A-KEY1", VERSION001);
176         final PfConceptKey aKey2 = new PfConceptKey("A-KEY2", VERSION001);
177         final DummyConceptEntity keyInfo0 = new DummyConceptEntity(aKey0,
178                 UUID.fromString(UUID0), DESCRIPTION0);
179         final DummyConceptEntity keyInfo1 = new DummyConceptEntity(aKey1,
180                 UUID.fromString(UUID1), DESCRIPTION1);
181         final DummyConceptEntity keyInfo2 = new DummyConceptEntity(aKey2,
182                 UUID.fromString(UUID2), DESCRIPTION2);
183
184         pfDao.create(keyInfo0);
185
186         final DummyConceptEntity keyInfoBack0 = pfDao.get(DummyConceptEntity.class, aKey0);
187         assertTrue(keyInfo0.equals(keyInfoBack0));
188
189         final DummyConceptEntity keyInfoBackNull = pfDao.get(DummyConceptEntity.class, PfConceptKey.getNullKey());
190         assertNull(keyInfoBackNull);
191
192         final DummyConceptEntity keyInfoBack1 = pfDao.getConcept(DummyConceptEntity.class, aKey0);
193         assertTrue(keyInfoBack0.equals(keyInfoBack1));
194
195         final DummyConceptEntity keyInfoBack2 =
196                 pfDao.getConcept(DummyConceptEntity.class, new PfConceptKey("A-KEY3", VERSION001));
197         assertNull(keyInfoBack2);
198
199         final Set<DummyConceptEntity> keyInfoSetIn = new TreeSet<>();
200         keyInfoSetIn.add(keyInfo1);
201         keyInfoSetIn.add(keyInfo2);
202
203         pfDao.createCollection(keyInfoSetIn);
204
205         Set<DummyConceptEntity> keyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyConceptEntity.class));
206
207         keyInfoSetIn.add(keyInfo0);
208         assertTrue(keyInfoSetIn.equals(keyInfoSetOut));
209
210         pfDao.delete(keyInfo1);
211         keyInfoSetIn.remove(keyInfo1);
212         keyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyConceptEntity.class));
213         assertTrue(keyInfoSetIn.equals(keyInfoSetOut));
214
215         pfDao.deleteCollection(keyInfoSetIn);
216         keyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyConceptEntity.class));
217         assertEquals(0, keyInfoSetOut.size());
218
219         keyInfoSetIn.add(keyInfo0);
220         keyInfoSetIn.add(keyInfo1);
221         keyInfoSetIn.add(keyInfo0);
222         pfDao.createCollection(keyInfoSetIn);
223         keyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyConceptEntity.class));
224         assertTrue(keyInfoSetIn.equals(keyInfoSetOut));
225
226         pfDao.delete(DummyConceptEntity.class, aKey0);
227         keyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyConceptEntity.class));
228         assertEquals(2, keyInfoSetOut.size());
229         assertEquals(2, pfDao.size(DummyConceptEntity.class));
230
231         final Set<PfConceptKey> keySetIn = new TreeSet<>();
232         keySetIn.add(aKey1);
233         keySetIn.add(aKey2);
234
235         final int deletedCount = pfDao.deleteByConceptKey(DummyConceptEntity.class, keySetIn);
236         assertEquals(2, deletedCount);
237
238         keyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyConceptEntity.class));
239         assertEquals(0, keyInfoSetOut.size());
240
241         keyInfoSetIn.add(keyInfo0);
242         keyInfoSetIn.add(keyInfo1);
243         keyInfoSetIn.add(keyInfo0);
244         pfDao.createCollection(keyInfoSetIn);
245         keyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyConceptEntity.class));
246         assertTrue(keyInfoSetIn.equals(keyInfoSetOut));
247
248         pfDao.deleteAll(DummyConceptEntity.class);
249         assertEquals(0, pfDao.size(DummyConceptEntity.class));
250
251         final PfConceptKey owner0Key = new PfConceptKey("Owner0", VERSION001);
252         final PfConceptKey owner1Key = new PfConceptKey("Owner1", VERSION001);
253         final PfConceptKey owner2Key = new PfConceptKey("Owner2", VERSION001);
254         final PfConceptKey owner3Key = new PfConceptKey("Owner3", VERSION001);
255         final PfConceptKey owner4Key = new PfConceptKey("Owner4", VERSION001);
256         final PfConceptKey owner5Key = new PfConceptKey("Owner5", VERSION001);
257
258         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner0Key, ENTITY0), 100.0));
259         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner0Key, "Entity1"), 101.0));
260         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner0Key, "Entity2"), 102.0));
261         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner0Key, "Entity3"), 103.0));
262         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner0Key, "Entity4"), 104.0));
263         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner1Key, "Entity5"), 105.0));
264         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner1Key, "Entity6"), 106.0));
265         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner1Key, "Entity7"), 107.0));
266         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner2Key, "Entity8"), 108.0));
267         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner2Key, "Entity9"), 109.0));
268         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner3Key, "EntityA"), 110.0));
269         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner4Key, "EntityB"), 111.0));
270         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner5Key, "EntityC"), 112.0));
271         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner5Key, "EntityD"), 113.0));
272         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner5Key, "EntityE"), 114.0));
273         pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner5Key, "EntityF"), 115.0));
274
275         TreeSet<DummyReferenceEntity> testEntitySetOut =
276                 new TreeSet<>(pfDao.getAll(DummyReferenceEntity.class));
277         assertEquals(16, testEntitySetOut.size());
278
279         testEntitySetOut = new TreeSet<>(pfDao.getAll(DummyReferenceEntity.class, owner0Key));
280         assertEquals(5, testEntitySetOut.size());
281
282         testEntitySetOut = new TreeSet<>(pfDao.getAll(DummyReferenceEntity.class, owner1Key));
283         assertEquals(3, testEntitySetOut.size());
284
285         testEntitySetOut = new TreeSet<>(pfDao.getAll(DummyReferenceEntity.class, owner2Key));
286         assertEquals(2, testEntitySetOut.size());
287
288         testEntitySetOut = new TreeSet<>(pfDao.getAll(DummyReferenceEntity.class, owner3Key));
289         assertEquals(1, testEntitySetOut.size());
290
291         testEntitySetOut = new TreeSet<>(pfDao.getAll(DummyReferenceEntity.class, owner4Key));
292         assertEquals(1, testEntitySetOut.size());
293
294         testEntitySetOut = new TreeSet<>(pfDao.getAll(DummyReferenceEntity.class, owner5Key));
295         assertEquals(4, testEntitySetOut.size());
296
297         assertNotNull(pfDao.get(DummyReferenceEntity.class, new PfReferenceKey(owner0Key, ENTITY0)));
298         assertNotNull(pfDao.getConcept(DummyReferenceEntity.class, new PfReferenceKey(owner0Key, ENTITY0)));
299         assertNull(pfDao.get(DummyReferenceEntity.class, new PfReferenceKey(owner0Key, "Entity1000")));
300         assertNull(pfDao.getConcept(DummyReferenceEntity.class, new PfReferenceKey(owner0Key, "Entity1000")));
301         pfDao.delete(DummyReferenceEntity.class, new PfReferenceKey(owner0Key, ENTITY0));
302
303         final Set<PfReferenceKey> rKeySetIn = new TreeSet<>();
304         rKeySetIn.add(new PfReferenceKey(owner4Key, "EntityB"));
305         rKeySetIn.add(new PfReferenceKey(owner5Key, "EntityD"));
306
307         final int deletedRCount = pfDao.deleteByReferenceKey(DummyReferenceEntity.class, rKeySetIn);
308         assertEquals(2, deletedRCount);
309
310         pfDao.update(new DummyReferenceEntity(new PfReferenceKey(owner5Key, "EntityF"), 120.0));
311
312         final PfTimestampKey atKey0 = new PfTimestampKey("AT-KEY0", VERSION001, TIMESTAMP0);
313         final PfTimestampKey atKey1 = new PfTimestampKey("AT-KEY1", VERSION001, TIMESTAMP1);
314         final PfTimestampKey atKey2 = new PfTimestampKey("AT-KEY2", VERSION001, TIMESTAMP2);
315         final DummyTimestampEntity tkeyInfo0 = new DummyTimestampEntity(atKey0, 200.0);
316         final DummyTimestampEntity tkeyInfo1 = new DummyTimestampEntity(atKey1, 200.1);
317         final DummyTimestampEntity tkeyInfo2 = new DummyTimestampEntity(atKey2, 200.2);
318
319         pfDao.create(tkeyInfo0);
320
321         final DummyTimestampEntity tkeyInfoBack0 = pfDao.get(DummyTimestampEntity.class, atKey0);
322         assertEquals(tkeyInfo0, tkeyInfoBack0);
323
324         final DummyTimestampEntity tkeyInfoBackNull =
325                 pfDao.get(DummyTimestampEntity.class, PfTimestampKey.getNullKey());
326         assertNull(tkeyInfoBackNull);
327
328
329
330         final Set<DummyTimestampEntity> tkeyInfoSetIn = new TreeSet<>();
331         tkeyInfoSetIn.add(tkeyInfo1);
332         tkeyInfoSetIn.add(tkeyInfo2);
333
334         pfDao.createCollection(tkeyInfoSetIn);
335
336         Set<DummyTimestampEntity> tkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyTimestampEntity.class));
337
338         tkeyInfoSetIn.add(tkeyInfo0);
339         assertEquals(tkeyInfoSetIn, tkeyInfoSetOut);
340
341         pfDao.delete(tkeyInfo1);
342         tkeyInfoSetIn.remove(tkeyInfo1);
343         tkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyTimestampEntity.class));
344         assertEquals(tkeyInfoSetIn, tkeyInfoSetOut);
345
346         pfDao.deleteCollection(tkeyInfoSetIn);
347         tkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyTimestampEntity.class));
348         assertEquals(0, tkeyInfoSetOut.size());
349
350         tkeyInfoSetIn.add(tkeyInfo2);
351         pfDao.createCollection(tkeyInfoSetIn);
352         tkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyTimestampEntity.class));
353         assertEquals(keyInfoSetIn, keyInfoSetOut);
354
355         pfDao.delete(DummyTimestampEntity.class, atKey2);
356         tkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyTimestampEntity.class));
357         assertEquals(3, keyInfoSetOut.size());
358         assertEquals(1, pfDao.size(DummyTimestampEntity.class));
359
360         pfDao.deleteAll(DummyTimestampEntity.class);
361         assertEquals(0, pfDao.size(DummyTimestampEntity.class));
362     }
363
364     private void testVersionOps() {
365         final PfConceptKey aKey0 = new PfConceptKey("AAA0", VERSION001);
366         final PfConceptKey aKey1 = new PfConceptKey("AAA0", VERSION002);
367         final PfConceptKey aKey2 = new PfConceptKey("AAA0", VERSION003);
368         final PfConceptKey bKey0 = new PfConceptKey("BBB0", VERSION001);
369         final PfConceptKey bKey1 = new PfConceptKey("BBB0", VERSION002);
370         final PfConceptKey bKey2 = new PfConceptKey("BBB0", VERSION003);
371         final DummyConceptEntity keyInfo0 = new DummyConceptEntity(aKey0,
372                 UUID.fromString(UUID0), DESCRIPTION0);
373         final DummyConceptEntity keyInfo1 = new DummyConceptEntity(aKey1,
374                 UUID.fromString(UUID1), DESCRIPTION1);
375         final DummyConceptEntity keyInfo2 = new DummyConceptEntity(aKey2,
376                 UUID.fromString(UUID2), DESCRIPTION2);
377         final DummyConceptEntity keyInfo3 = new DummyConceptEntity(bKey0,
378                 UUID.fromString(UUID0), DESCRIPTION0);
379         final DummyConceptEntity keyInfo4 = new DummyConceptEntity(bKey1,
380                 UUID.fromString(UUID1), DESCRIPTION1);
381         final DummyConceptEntity keyInfo5 = new DummyConceptEntity(bKey2,
382                 UUID.fromString(UUID2), DESCRIPTION2);
383
384         pfDao.create(keyInfo0);
385         pfDao.create(keyInfo1);
386         pfDao.create(keyInfo2);
387         pfDao.create(keyInfo3);
388         pfDao.create(keyInfo4);
389         pfDao.create(keyInfo5);
390
391         assertEquals(3, pfDao.getAllVersions(DummyConceptEntity.class, "AAA0").size());
392         assertEquals(0, pfDao.getAllVersions(null, "AAA0").size());
393         assertEquals(0, pfDao.getAllVersions(DummyConceptEntity.class, null).size());
394     }
395
396     private void testgetFilteredOps() {
397         final PfConceptKey aKey0 = new PfConceptKey("AAA0", VERSION001);
398         final PfConceptKey aKey1 = new PfConceptKey("AAA0", VERSION002);
399         final PfConceptKey aKey2 = new PfConceptKey("AAA0", VERSION003);
400         final PfConceptKey bKey0 = new PfConceptKey("BBB0", VERSION001);
401         final PfConceptKey bKey1 = new PfConceptKey("BBB0", VERSION002);
402         final PfConceptKey bKey2 = new PfConceptKey("BBB0", VERSION003);
403         final DummyConceptEntity keyInfo0 = new DummyConceptEntity(aKey0,
404                 UUID.fromString(UUID0), DESCRIPTION0);
405         final DummyConceptEntity keyInfo1 = new DummyConceptEntity(aKey1,
406                 UUID.fromString(UUID1), DESCRIPTION1);
407         final DummyConceptEntity keyInfo2 = new DummyConceptEntity(aKey2,
408                 UUID.fromString(UUID2), DESCRIPTION2);
409         final DummyConceptEntity keyInfo3 = new DummyConceptEntity(bKey0,
410                 UUID.fromString(UUID0), DESCRIPTION0);
411         final DummyConceptEntity keyInfo4 = new DummyConceptEntity(bKey1,
412                 UUID.fromString(UUID1), DESCRIPTION1);
413         final DummyConceptEntity keyInfo5 = new DummyConceptEntity(bKey2,
414                 UUID.fromString(UUID2), DESCRIPTION2);
415
416         pfDao.create(keyInfo0);
417         pfDao.create(keyInfo1);
418         pfDao.create(keyInfo2);
419         pfDao.create(keyInfo3);
420         pfDao.create(keyInfo4);
421         pfDao.create(keyInfo5);
422
423         assertEquals(6, pfDao.getFiltered(DummyConceptEntity.class, null, null).size());
424         assertEquals(3, pfDao.getFiltered(DummyConceptEntity.class, "AAA0", null).size());
425         assertEquals(3, pfDao.getFiltered(DummyConceptEntity.class, "BBB0", null).size());
426         assertEquals(1, pfDao.getFiltered(DummyConceptEntity.class, "BBB0", VERSION003).size());
427         assertEquals(6, pfDao.getFiltered(DummyConceptEntity.class, null, VERSION003).size());
428
429         final PfTimestampKey atKey0 = new PfTimestampKey("AT-KEY0", VERSION001, TIMESTAMP0);
430         final PfTimestampKey atKey1 = new PfTimestampKey("AT-KEY1", VERSION001, TIMESTAMP1);
431         final PfTimestampKey atKey2 = new PfTimestampKey("AT-KEY2", VERSION001, TIMESTAMP2);
432         final DummyTimestampEntity tkeyInfo0 = new DummyTimestampEntity(atKey0, 200.0);
433         final DummyTimestampEntity tkeyInfo1 = new DummyTimestampEntity(atKey1, 200.1);
434         final DummyTimestampEntity tkeyInfo2 = new DummyTimestampEntity(atKey2, 200.2);
435
436         pfDao.create(tkeyInfo0);
437         pfDao.create(tkeyInfo1);
438         pfDao.create(tkeyInfo2);
439
440
441         assertEquals(1, pfDao
442                 .getFiltered(DummyTimestampEntity.class, "AT-KEY0", VERSION001, null, null, null, "DESC", 0).size());
443         assertEquals(1,
444                 pfDao.getFiltered(DummyTimestampEntity.class, "AT-KEY0", null, null, null, null, "DESC", 0).size());
445         assertEquals(3, pfDao
446                 .getFiltered(DummyTimestampEntity.class, null, VERSION001, TIMESTAMP0, TIMESTAMP2, null, "DESC", 0)
447                 .size());
448         assertEquals(1, pfDao
449                 .getFiltered(DummyTimestampEntity.class, "AT-KEY0", VERSION001, TIMESTAMP0, TIMESTAMP2, null, "DESC", 0)
450                 .size());
451         assertEquals(3, pfDao
452                 .getFiltered(DummyTimestampEntity.class, null, VERSION001, null, TIMESTAMP2, null, "DESC", 0).size());
453         assertEquals(3, pfDao
454                 .getFiltered(DummyTimestampEntity.class, null, VERSION001, TIMESTAMP0, null, null, "DESC", 0).size());
455         assertEquals(2,
456                 pfDao.getFiltered(DummyTimestampEntity.class, null, VERSION001, TIMESTAMP0, TIMESTAMP2, null, "DESC", 2)
457                         .size());
458
459         Map<String, Object> filterMap = new HashMap<>();
460         filterMap.put("doubleValue", 200.1);
461         assertEquals(1,
462                 pfDao.getFiltered(DummyTimestampEntity.class, null, null, null, null, filterMap, "DESC", 0).size());
463
464     }
465 }