X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-pdp%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fmodels%2Fpdp%2Fpersistence%2Fprovider%2FPdpProviderTest.java;h=4c6a461421f8224d7cc2a5bda9ed58f896cbc7fd;hb=389c85c8e7213c10c17896f4c63d94e2b5e9d27a;hp=80c906e5fcca481146363c3d4f24aab0465343b7;hpb=e53df8d3f8ab0464b0876bdb339fa91dc9085cd2;p=policy%2Fmodels.git diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java index 80c906e5f..4c6a46142 100644 --- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java @@ -1,7 +1,8 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021,2023 Nordix Foundation. + * Copyright (C) 2019-2021, 2023-2024 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 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. @@ -51,7 +52,6 @@ import org.onap.policy.models.pdp.concepts.PdpGroups; import org.onap.policy.models.pdp.concepts.PdpPolicyStatus; import org.onap.policy.models.pdp.concepts.PdpPolicyStatus.PdpPolicyStatusBuilder; import org.onap.policy.models.pdp.concepts.PdpPolicyStatus.State; -import org.onap.policy.models.pdp.concepts.PdpStatistics; import org.onap.policy.models.pdp.concepts.PdpSubGroup; import org.onap.policy.models.pdp.enums.PdpHealthStatus; import org.onap.policy.models.pdp.enums.PdpState; @@ -93,15 +93,15 @@ public class PdpProviderTest { daoParameters.setPersistenceUnit("ToscaConceptTest"); Properties jdbcProperties = new Properties(); - jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy"); - jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY"); + jdbcProperties.setProperty("jakarta.persistence.jdbc.user", "policy"); + jdbcProperties.setProperty("jakarta.persistence.jdbc.password", "P01icY"); if (System.getProperty("USE-MARIADB") != null) { - jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver"); - jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/policy"); + jdbcProperties.setProperty("jakarta.persistence.jdbc.driver", "org.mariadb.jdbc.Driver"); + jdbcProperties.setProperty("jakarta.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/policy"); } else { - jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver"); - jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:PdpProviderTest"); + jdbcProperties.setProperty("jakarta.persistence.jdbc.driver", "org.h2.Driver"); + jdbcProperties.setProperty("jakarta.persistence.jdbc.url", "jdbc:h2:mem:PdpProviderTest"); } daoParameters.setJdbcProperties(jdbcProperties); @@ -507,151 +507,6 @@ public class PdpProviderTest { existingPdp.setMessage("A Message"); } - @Test - public void testGetPdpStatistics() throws PfModelException { - assertThatThrownBy(() -> { - new PdpProvider().getPdpStatistics(null, null); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().getPdpStatistics(null, "name"); - }).hasMessageMatching(DAO_IS_NULL); - - assertEquals(0, new PdpProvider().getPdpStatistics(pfDao, "name").size()); - } - - @Test - public void testUpdatePdpStatisticsDao() throws PfModelException { - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, null, null, null); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, null, null, new PdpStatistics()); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, null, "inst", null); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, null, "inst", new PdpStatistics()); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, "TYPE", null, null); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, "TYPE", null, new PdpStatistics()); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, "TYPE", "inst", null); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, null, "TYPE", "inst", new PdpStatistics()); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", null, null, null); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", null, null, new PdpStatistics()); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", null, "inst", null); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", null, "inst", new PdpStatistics()); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", "TYPE", null, null); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", "TYPE", null, new PdpStatistics()); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", "TYPE", "inst", null); - }).hasMessageMatching(DAO_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(null, "name", "TYPE", "inst", new PdpStatistics()); - }).hasMessageMatching(DAO_IS_NULL); - } - - @Test - public void testUpdatePdpStatisticsGroup() throws PfModelException { - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, null, null, null); - }).hasMessageMatching(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, null, null, new PdpStatistics()); - }).hasMessageMatching(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, null, "inst", null); - }).hasMessageMatching(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, null, "inst", new PdpStatistics()); - }).hasMessageMatching(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", null, null); - }).hasMessageMatching(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", null, new PdpStatistics()); - }).hasMessageMatching(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", "inst", null); - }).hasMessageMatching(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", "inst", new PdpStatistics()); - }).hasMessageMatching(GROUP_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, null); - }).hasMessageMatching(PDP_TYPE_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", null, null, new PdpStatistics()); - }).hasMessageMatching(PDP_TYPE_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", null, "inst", null); - }).hasMessageMatching(PDP_TYPE_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", null, "inst", new PdpStatistics()); - }).hasMessageMatching(PDP_TYPE_IS_NULL); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", null, null); - }).hasMessageMatching("pdpInstanceId is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", null, new PdpStatistics()); - }).hasMessageMatching("pdpInstanceId is marked .*ull but is null"); - - assertThatThrownBy(() -> { - new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", "inst", null); - }).hasMessageMatching("pdpStatistics is marked .*ull but is null"); - - new PdpProvider().updatePdpStatistics(pfDao, "name", "TYPE", "inst", new PdpStatistics()); - } - @Test public void testGetAllPolicyStatusPfDao() throws PfModelException { assertThatThrownBy(() -> {