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