diff options
Diffstat (limited to 'models-dao')
5 files changed, 4 insertions, 421 deletions
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java index 7358ab11b..380a9831e 100644 --- a/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java +++ b/models-dao/src/main/java/org/onap/policy/models/dao/PfDao.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,12 +22,10 @@ package org.onap.policy.models.dao; -import java.time.Instant; import java.util.Collection; import java.util.List; import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfGeneratedIdKey; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfReferenceTimestampKey; @@ -95,15 +94,6 @@ public interface PfDao { <T extends PfConcept> void delete(Class<T> someClass, PfTimestampKey timeStampKey); /** - * Delete an Policy Framework concept on the database. - * - * @param <T> the type of the object to delete, a subclass of {@link PfConcept} - * @param someClass the class of the object to delete, a subclass of {@link PfConcept} - * @param idKey the PfConceptIdKey of the object to delete - */ - <T extends PfConcept> void delete(Class<T> someClass, PfGeneratedIdKey idKey); - - /** * Create a collection of objects in the database. * * @param <T> the type of the object to create, a subclass of {@link PfConcept} @@ -203,16 +193,6 @@ public interface PfDao { <T extends PfConcept> T get(Class<T> someClass, PfTimestampKey timestampKey); /** - * Get an object from the database, referred to by reference key. - * - * @param <T> the type of the object to get, a subclass of {@link PfConcept} - * @param someClass the class of the object to get, a subclass of {@link PfConcept} - * @param idKey the PfConceptIdKey of the object to get - * @return the object that was retrieved from the database or null if the object was not retrieved - */ - <T extends PfConcept> T get(Class<T> someClass, PfGeneratedIdKey idKey); - - /** * Get an object from the database, referred to by reference timestamp key. * * @param <T> the type of the object to get, a subclass of {@link PfConcept} @@ -273,18 +253,6 @@ public interface PfDao { <T extends PfConcept> List<T> getAllVersionsByParent(Class<T> someClass, final String parentKeyName); /** - * Get all the objects in the database of a given type. - * - * @param <T> the type of the objects to get, a subclass of {@link PfConcept} - * @param someClass the class of the objects to get, a subclass of {@link PfConcept} - * @param key the key of the PfGeneratedIdKey to get - * @param timeStamp the timeStamp of the concepts to get - * @return the objects or null if no objects were retrieved - */ - <T extends PfConcept> List<T> getByTimestamp(final Class<T> someClass, - final PfGeneratedIdKey key, final Instant timeStamp); - - /** * Get a concept from the database with the given concept key. * * @param <T> the type of the object to get, a subclass of {@link PfConcept} diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java index 1b1b77da2..22c5c5397 100644 --- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java +++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,8 +22,6 @@ package org.onap.policy.models.dao.impl; -import java.sql.Timestamp; -import java.time.Instant; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -34,7 +33,6 @@ import javax.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfGeneratedIdKey; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfModelRuntimeException; import org.onap.policy.models.base.PfReferenceKey; @@ -60,7 +58,6 @@ public class DefaultPfDao implements PfDao { private static final String NAME = "name"; private static final String VERSION = "version"; private static final String TIMESTAMP = "timeStamp"; - private static final String GENERATEDID = "Id"; private static final String PARENT_NAME = "parentname"; private static final String PARENT_VERSION = "parentversion"; private static final String LOCAL_NAME = "localname"; @@ -78,8 +75,6 @@ public class DefaultPfDao implements PfDao { private static final String NAME_FILTER = "c.key.name = :name"; private static final String VERSION_FILTER = "c.key.version = :version"; private static final String TIMESTAMP_FILTER = "c.key.timeStamp = :timeStamp"; - private static final String TIMESTAMP_FILTER_NOKEY = "c.timeStamp = :timeStamp"; - private static final String GENERATED_ID_FILTER = "c.key.generatedId = :Id"; private static final String PARENT_NAME_FILTER = "c.key.parentKeyName = :parentname"; private static final String PARENT_VERSION_FILTER = "c.key.parentKeyVersion = :parentversion"; private static final String LOCAL_NAME_FILTER = "c.key.localName = :localname"; @@ -92,9 +87,6 @@ public class DefaultPfDao implements PfDao { private static final String DELETE_BY_TIMESTAMP_KEY = DELETE_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER + AND + TIMESTAMP_FILTER; - private static final String DELETE_BY_GENERATED_ID_KEY = - DELETE_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER + AND + GENERATED_ID_FILTER; - private static final String DELETE_BY_REFERENCE_KEY = DELETE_FROM_TABLE + WHERE + PARENT_NAME_FILTER + AND + PARENT_VERSION_FILTER + AND + LOCAL_NAME_FILTER; @@ -109,9 +101,6 @@ public class DefaultPfDao implements PfDao { private static final String SELECT_BY_CONCEPT_KEY = SELECT_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER; - private static final String SELECT_BY_TIMESTAMP_NOKEY = - SELECT_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER + AND + TIMESTAMP_FILTER_NOKEY; - private static final String SELECT_BY_REFERENCE_KEY = SELECT_FROM_TABLE + WHERE + PARENT_NAME_FILTER + AND + PARENT_VERSION_FILTER + AND + LOCAL_NAME_FILTER; // @formatter:on @@ -255,27 +244,6 @@ public class DefaultPfDao implements PfDao { } @Override - public <T extends PfConcept> void delete(final Class<T> someClass, final PfGeneratedIdKey key) { - if (key == null) { - return; - } - final var mg = getEntityManager(); - try { - // @formatter:off - mg.getTransaction().begin(); - mg.createQuery(setQueryTable(DELETE_BY_GENERATED_ID_KEY, someClass), someClass) - .setParameter(NAME, key.getName()) - .setParameter(VERSION, key.getVersion()) - .setParameter(GENERATEDID, key.getGeneratedId()) - .executeUpdate(); - mg.getTransaction().commit(); - // @formatter:on - } finally { - mg.close(); - } - } - - @Override public <T extends PfConcept> void createCollection(final Collection<T> objs) { if (objs == null || objs.isEmpty()) { return; @@ -418,11 +386,6 @@ public class DefaultPfDao implements PfDao { } @Override - public <T extends PfConcept> T get(final Class<T> someClass, final PfGeneratedIdKey key) { - return genericGet(someClass, key); - } - - @Override public <T extends PfConcept> T get(final Class<T> someClass, final PfTimestampKey key) { return genericGet(someClass, key); } @@ -535,27 +498,6 @@ public class DefaultPfDao implements PfDao { } @Override - public <T extends PfConcept> List<T> getByTimestamp(final Class<T> someClass, final PfGeneratedIdKey key, - final Instant timeStamp) { - if (someClass == null || key == null || timeStamp == null) { - return Collections.emptyList(); - } - - final var mg = getEntityManager(); - try { - // @formatter:off - return mg.createQuery(setQueryTable(SELECT_BY_TIMESTAMP_NOKEY, someClass), someClass) - .setParameter(NAME, key.getName()) - .setParameter(VERSION, key.getVersion()) - .setParameter(TIMESTAMP, Timestamp.from(timeStamp)) - .getResultList(); - // @formatter:on - } finally { - mg.close(); - } - } - - @Override public <T extends PfConcept> T getConcept(final Class<T> someClass, final PfConceptKey key) { if (someClass == null || key == null) { return null; diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/ProxyDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/ProxyDao.java index 72d56834d..d0681e1e4 100644 --- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/ProxyDao.java +++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/ProxyDao.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +21,6 @@ package org.onap.policy.models.dao.impl; -import java.sql.Timestamp; -import java.time.Instant; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -32,7 +31,6 @@ import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfGeneratedIdKey; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfReferenceTimestampKey; @@ -58,7 +56,6 @@ public class ProxyDao implements PfDao { private static final String NAME = "name"; private static final String VERSION = "version"; private static final String TIMESTAMP = "timeStamp"; - private static final String GENERATEDID = "Id"; private static final String PARENT_NAME = "parentname"; private static final String PARENT_VERSION = "parentversion"; private static final String LOCAL_NAME = "localname"; @@ -76,8 +73,6 @@ public class ProxyDao implements PfDao { private static final String NAME_FILTER = "c.key.name = :name"; private static final String VERSION_FILTER = "c.key.version = :version"; private static final String TIMESTAMP_FILTER = "c.key.timeStamp = :timeStamp"; - private static final String TIMESTAMP_FILTER_NOKEY = "c.timeStamp = :timeStamp"; - private static final String GENERATED_ID_FILTER = "c.key.generatedId = :Id"; private static final String PARENT_NAME_FILTER = "c.key.parentKeyName = :parentname"; private static final String PARENT_VERSION_FILTER = "c.key.parentKeyVersion = :parentversion"; private static final String LOCAL_NAME_FILTER = "c.key.localName = :localname"; @@ -90,9 +85,6 @@ public class ProxyDao implements PfDao { private static final String DELETE_BY_TIMESTAMP_KEY = DELETE_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER + AND + TIMESTAMP_FILTER; - private static final String DELETE_BY_GENERATED_ID_KEY = - DELETE_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER + AND + GENERATED_ID_FILTER; - private static final String DELETE_BY_REFERENCE_KEY = DELETE_FROM_TABLE + WHERE + PARENT_NAME_FILTER + AND + PARENT_VERSION_FILTER + AND + LOCAL_NAME_FILTER; @@ -107,9 +99,6 @@ public class ProxyDao implements PfDao { private static final String SELECT_BY_CONCEPT_KEY = SELECT_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER; - private static final String SELECT_BY_TIMESTAMP_NOKEY = - SELECT_FROM_TABLE + WHERE + NAME_FILTER + AND + VERSION_FILTER + AND + TIMESTAMP_FILTER_NOKEY; - private static final String SELECT_BY_REFERENCE_KEY = SELECT_FROM_TABLE + WHERE + PARENT_NAME_FILTER + AND + PARENT_VERSION_FILTER + AND + LOCAL_NAME_FILTER; // @formatter:on @@ -187,21 +176,6 @@ public class ProxyDao implements PfDao { } @Override - public <T extends PfConcept> void delete(final Class<T> someClass, final PfGeneratedIdKey key) { - if (key == null) { - return; - } - - // @formatter:off - mg.createQuery(setQueryTable(DELETE_BY_GENERATED_ID_KEY, someClass), someClass) - .setParameter(NAME, key.getName()) - .setParameter(VERSION, key.getVersion()) - .setParameter(GENERATEDID, key.getGeneratedId()) - .executeUpdate(); - // @formatter:on - } - - @Override public <T extends PfConcept> void createCollection(final Collection<T> objs) { if (objs == null || objs.isEmpty()) { return; @@ -308,11 +282,6 @@ public class ProxyDao implements PfDao { } @Override - public <T extends PfConcept> T get(final Class<T> someClass, final PfGeneratedIdKey key) { - return genericGet(someClass, key); - } - - @Override public <T extends PfConcept> T get(final Class<T> someClass, final PfTimestampKey key) { return genericGet(someClass, key); } @@ -397,22 +366,6 @@ public class ProxyDao implements PfDao { } @Override - public <T extends PfConcept> List<T> getByTimestamp(final Class<T> someClass, final PfGeneratedIdKey key, - final Instant timeStamp) { - if (someClass == null || key == null || timeStamp == null) { - return Collections.emptyList(); - } - - // @formatter:off - return mg.createQuery(setQueryTable(SELECT_BY_TIMESTAMP_NOKEY, someClass), someClass) - .setParameter(NAME, key.getName()) - .setParameter(VERSION, key.getVersion()) - .setParameter(TIMESTAMP, Timestamp.from(timeStamp)) - .getResultList(); - // @formatter:on - } - - @Override public <T extends PfConcept> T getConcept(final Class<T> someClass, final PfConceptKey key) { if (someClass == null || key == null) { return null; diff --git a/models-dao/src/test/java/org/onap/policy/models/dao/DummyGeneratedIdEntity.java b/models-dao/src/test/java/org/onap/policy/models/dao/DummyGeneratedIdEntity.java deleted file mode 100644 index 6ba045c54..000000000 --- a/models-dao/src/test/java/org/onap/policy/models/dao/DummyGeneratedIdEntity.java +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.dao; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NonNull; -import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.base.PfGeneratedIdKey; -import org.onap.policy.models.base.PfKey; - - -@Entity -@Table(name = "DummyGeneratedIdEntity") -@Data -@EqualsAndHashCode(callSuper = false) -public class DummyGeneratedIdEntity extends PfConcept { - private static final long serialVersionUID = -2962570563281067896L; - - @EmbeddedId() - @NonNull - private PfGeneratedIdKey key; - - @Column(precision = 3) - @Temporal(TemporalType.TIMESTAMP) - private Date timeStamp; - - @Column - private double doubleValue; - - /** - * Default constructor. - */ - public DummyGeneratedIdEntity() { - this.key = new PfGeneratedIdKey(); - this.timeStamp = new Date(); - } - - public DummyGeneratedIdEntity(DummyGeneratedIdEntity source) { - this.key = source.key; - this.timeStamp = source.timeStamp; - } - - /** - * Constructor. - * - * @param key the key - * @param timeStamp the date value - */ - public DummyGeneratedIdEntity(final PfGeneratedIdKey key, final Date timeStamp) { - this.key = key; - this.timeStamp = timeStamp; - } - - /** - * Constructor. - * - * @param key the key - * @param timeStamp the date value - * @param doubleValue the double value * - */ - public DummyGeneratedIdEntity(final PfGeneratedIdKey key, final Date timeStamp, final double doubleValue) { - this.key = key; - this.timeStamp = timeStamp; - this.doubleValue = doubleValue; - } - - @Override - public List<PfKey> getKeys() { - final List<PfKey> keyList = new ArrayList<>(); - keyList.add(getKey()); - return keyList; - } - - @Override - public BeanValidationResult validate(@NonNull String fieldName) { - BeanValidationResult result = new BeanValidationResult(fieldName, this); - result.addResult(key.validate("key")); - return result; - } - - @Override - public void clean() { - key.clean(); - } - - @Override - public int compareTo(@NonNull final PfConcept otherObj) { - if (this == otherObj) { - return 0; - } - - if (getClass() != otherObj.getClass()) { - return this.getClass().getName().compareTo(otherObj.getClass().getName()); - } - - final DummyGeneratedIdEntity other = (DummyGeneratedIdEntity) otherObj; - if (this.timeStamp != other.timeStamp) { - return timeStamp.compareTo(other.timeStamp); - } - return Double.compare(doubleValue, other.doubleValue); - } - -} diff --git a/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java b/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java index c0b0f2ad0..65d22863f 100644 --- a/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java +++ b/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +31,6 @@ import static org.junit.Assert.assertNull; import java.time.Instant; import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -42,7 +42,6 @@ import org.eclipse.persistence.config.PersistenceUnitProperties; import org.junit.After; import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfGeneratedIdKey; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfReferenceTimestampKey; @@ -66,9 +65,6 @@ public class EntityTest { private static final Instant TIMESTAMP0 = Instant.ofEpochSecond(1613494293); private static final Instant TIMESTAMP1 = Instant.ofEpochSecond(1613494293).plusSeconds(55); private static final Instant TIMESTAMP2 = Instant.ofEpochSecond(1613494293).plusSeconds(90); - private static final Long GENERATEDID0 = 10000L; - private static final Long GENERATEDID1 = 10001L; - private static final Long GENERATEDID2 = 10002L; private PfDao pfDao; @@ -134,16 +130,12 @@ public class EntityTest { testAllOps(); - testGeneratedId(); - testReferenceTimestamp(); testVersionOps(); testgetFilteredOps(); - testgetFilteredOps2(); - testgetFilteredOps3(); } @@ -384,111 +376,6 @@ public class EntityTest { assertEquals(0, pfDao.size(DummyTimestampEntity.class)); } - private void testGeneratedId() { - final PfGeneratedIdKey agKey0 = new PfGeneratedIdKey("AT-KEY0", VERSION001, GENERATEDID0); - final PfGeneratedIdKey agKey1 = new PfGeneratedIdKey("AT-KEY1", VERSION001, GENERATEDID1); - final PfGeneratedIdKey agKey2 = new PfGeneratedIdKey("AT-KEY2", VERSION001, GENERATEDID2); - final DummyGeneratedIdEntity gkeyInfo0 = new DummyGeneratedIdEntity(agKey0, Date.from(TIMESTAMP0)); - final DummyGeneratedIdEntity gkeyInfo1 = new DummyGeneratedIdEntity(agKey1, Date.from(TIMESTAMP1)); - final DummyGeneratedIdEntity gkeyInfo2 = new DummyGeneratedIdEntity(agKey2, Date.from(TIMESTAMP2)); - - pfDao.create(gkeyInfo0); - - final DummyGeneratedIdEntity gkeyInfoBack0 = pfDao.get(DummyGeneratedIdEntity.class, agKey0); - assertEquals(gkeyInfo0, gkeyInfoBack0); - - assertEquals(1, pfDao.getByTimestamp(DummyGeneratedIdEntity.class, agKey0, TIMESTAMP0).size()); - - final DummyGeneratedIdEntity gkeyInfoBackNull = - pfDao.get(DummyGeneratedIdEntity.class, PfGeneratedIdKey.getNullKey()); - assertNull(gkeyInfoBackNull); - - final Set<DummyGeneratedIdEntity> gkeyInfoSetIn = new TreeSet<>(); - gkeyInfoSetIn.add(gkeyInfo1); - gkeyInfoSetIn.add(gkeyInfo2); - - pfDao.createCollection(gkeyInfoSetIn); - - Set<DummyGeneratedIdEntity> gkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyGeneratedIdEntity.class)); - - gkeyInfoSetIn.add(gkeyInfo0); - assertEquals(gkeyInfoSetIn, gkeyInfoSetOut); - - pfDao.delete(gkeyInfo1); - gkeyInfoSetIn.remove(gkeyInfo1); - gkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyGeneratedIdEntity.class)); - assertEquals(gkeyInfoSetIn, gkeyInfoSetOut); - - pfDao.deleteCollection(gkeyInfoSetIn); - gkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyGeneratedIdEntity.class)); - assertEquals(0, gkeyInfoSetOut.size()); - - gkeyInfoSetIn.add(gkeyInfo2); - pfDao.createCollection(gkeyInfoSetIn); - gkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyGeneratedIdEntity.class)); - assertEquals(gkeyInfoSetIn, gkeyInfoSetOut); - - pfDao.delete(DummyGeneratedIdEntity.class, agKey2); - gkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyGeneratedIdEntity.class)); - assertEquals(gkeyInfoSetOut.size(), pfDao.size(DummyGeneratedIdEntity.class)); - - pfDao.deleteAll(DummyGeneratedIdEntity.class); - assertEquals(0, pfDao.size(DummyGeneratedIdEntity.class)); - - final PfGeneratedIdKey agKey3 = new PfGeneratedIdKey("AT-KEY0", VERSION001); - final PfGeneratedIdKey agKey4 = new PfGeneratedIdKey("AT-KEY1", VERSION001); - final PfGeneratedIdKey agKey5 = new PfGeneratedIdKey("AT-KEY2", VERSION001); - final DummyGeneratedIdEntity gkeyInfo3 = new DummyGeneratedIdEntity(agKey3, Date.from(TIMESTAMP0)); - final DummyGeneratedIdEntity gkeyInfo4 = new DummyGeneratedIdEntity(agKey4, Date.from(TIMESTAMP1)); - final DummyGeneratedIdEntity gkeyInfo5 = new DummyGeneratedIdEntity(agKey5, Date.from(TIMESTAMP2)); - - pfDao.create(gkeyInfo3); - - final DummyGeneratedIdEntity gkeyInfoBack3 = pfDao.get(DummyGeneratedIdEntity.class, agKey3); - assertEquals(gkeyInfo3, gkeyInfoBack3); - - assertEquals(1, pfDao.getByTimestamp(DummyGeneratedIdEntity.class, agKey3, TIMESTAMP0).size()); - - assertEquals(1, gkeyInfo3.getKeys().size()); - - assertEquals(1, gkeyInfo4.compareTo(gkeyInfo3)); - - assertNull(gkeyInfo4.validate(VERSION002).getResult()); - - - gkeyInfoSetIn.clear(); - gkeyInfoSetIn.add(gkeyInfo4); - gkeyInfoSetIn.add(gkeyInfo5); - - pfDao.createCollection(gkeyInfoSetIn); - - gkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyGeneratedIdEntity.class)); - - gkeyInfoSetIn.add(gkeyInfo3); - assertEquals(gkeyInfoSetIn, gkeyInfoSetOut); - - pfDao.delete(gkeyInfo4); - gkeyInfoSetIn.remove(gkeyInfo4); - gkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyGeneratedIdEntity.class)); - assertEquals(gkeyInfoSetIn, gkeyInfoSetOut); - - pfDao.deleteCollection(gkeyInfoSetIn); - gkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyGeneratedIdEntity.class)); - assertEquals(0, gkeyInfoSetOut.size()); - - gkeyInfoSetIn.add(gkeyInfo5); - pfDao.createCollection(gkeyInfoSetIn); - gkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyGeneratedIdEntity.class)); - assertEquals(gkeyInfoSetIn, gkeyInfoSetOut); - - pfDao.delete(DummyGeneratedIdEntity.class, agKey5); - gkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyGeneratedIdEntity.class)); - assertEquals(gkeyInfoSetOut.size(), pfDao.size(DummyGeneratedIdEntity.class)); - - pfDao.deleteAll(DummyGeneratedIdEntity.class); - assertEquals(0, pfDao.size(DummyGeneratedIdEntity.class)); - } - private void testReferenceTimestamp() { final PfConceptKey owner0Key = new PfConceptKey("Owner0", VERSION001); final PfConceptKey owner1Key = new PfConceptKey("Owner1", VERSION001); @@ -638,41 +525,6 @@ public class EntityTest { PfFilterParameters.builder().filterMap(filterMap).build())).hasSize(1); } - private void testgetFilteredOps2() { - Map<String, Object> filterMap = new HashMap<>(); - filterMap.put("doubleValue", 200.1); - - final PfGeneratedIdKey agKey0 = new PfGeneratedIdKey("AT-KEY0", VERSION001); - final PfGeneratedIdKey agKey1 = new PfGeneratedIdKey("AT-KEY1", VERSION001); - final PfGeneratedIdKey agKey2 = new PfGeneratedIdKey("AT-KEY2", VERSION001); - final DummyGeneratedIdEntity gkeyInfo0 = new DummyGeneratedIdEntity(agKey0, Date.from(TIMESTAMP0), 200.0); - final DummyGeneratedIdEntity gkeyInfo1 = new DummyGeneratedIdEntity(agKey1, Date.from(TIMESTAMP1), 200.1); - final DummyGeneratedIdEntity gkeyInfo2 = new DummyGeneratedIdEntity(agKey2, Date.from(TIMESTAMP2), 200.2); - - pfDao.create(gkeyInfo0); - pfDao.create(gkeyInfo1); - pfDao.create(gkeyInfo2); - - - assertThat(pfDao.getFiltered(DummyGeneratedIdEntity.class, - PfFilterParameters.builder().name("AT-KEY0").version(VERSION001).build())).hasSize(1); - assertThat(pfDao.getFiltered(DummyGeneratedIdEntity.class, - PfFilterParameters.builder().name("AT-KEY0").build())).hasSize(1); - assertThat(pfDao.getFiltered(DummyGeneratedIdEntity.class, PfFilterParameters.builder().version(VERSION001) - .startTime(TIMESTAMP0).endTime(TIMESTAMP2).build())).hasSize(3); - assertThat(pfDao.getFiltered(DummyGeneratedIdEntity.class, PfFilterParameters.builder().name("AT-KEY0") - .version(VERSION001).startTime(TIMESTAMP0).endTime(TIMESTAMP2).build())).hasSize(1); - assertThat(pfDao.getFiltered(DummyGeneratedIdEntity.class, - PfFilterParameters.builder().version(VERSION001).endTime(TIMESTAMP2).build())).hasSize(3); - assertThat(pfDao.getFiltered(DummyGeneratedIdEntity.class, - PfFilterParameters.builder().version(VERSION001).startTime(TIMESTAMP0).build())).hasSize(3); - assertThat(pfDao.getFiltered(DummyGeneratedIdEntity.class, PfFilterParameters.builder().version(VERSION001) - .startTime(TIMESTAMP0).endTime(TIMESTAMP2).sortOrder("DESC").recordNum(2).build())).hasSize(2); - - assertThat(pfDao.getFiltered(DummyGeneratedIdEntity.class, - PfFilterParameters.builder().filterMap(filterMap).build())).hasSize(1); - } - private void testgetFilteredOps3() { Map<String, Object> filterMap = new HashMap<>(); filterMap.put("localName", "AT-KEY0"); |