/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2021 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021, 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. 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.
import java.util.List;
import java.util.Properties;
import org.apache.commons.lang3.ObjectUtils;
-import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
daoParameters.setPersistenceUnit("ToscaConceptTest");
Properties jdbcProperties = new Properties();
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "P01icY");
-
- // H2, use "org.mariadb.jdbc.Driver" and "jdbc:mariadb://localhost:3306/policy" for locally installed MariaDB
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
-
+ jdbcProperties.setProperty("jakarta.persistence.jdbc.user", "policy");
+ jdbcProperties.setProperty("jakarta.persistence.jdbc.password", "P01icY");
+ if (System.getProperty("USE-MARIADB") != null) {
+ jdbcProperties.setProperty("jakarta.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
+ jdbcProperties.setProperty("jakarta.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/policy");
+ } else {
+ jdbcProperties.setProperty("jakarta.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("jakarta.persistence.jdbc.url",
+ "jdbc:h2:mem:AuthorativeToscaProviderPolicyTypeTest");
+ }
daoParameters.setJdbcProperties(jdbcProperties);
pfDao = new PfDaoFactory().createPfDao(daoParameters);
ToscaEntityFilter.<ToscaPolicyType>builder().build());
ToscaPolicyType gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
- assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
- assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));
+ checkEqualsNameDescription(beforePolicyType, gotPolicyType);
gotServiceTemplate = new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao,
ToscaEntityFilter.<ToscaPolicyType>builder().name(policyTypeKey.getName()).build());
gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
- assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
- assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));
+ checkEqualsNameDescription(beforePolicyType, gotPolicyType);
gotServiceTemplate = new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao, ToscaEntityFilter
.<ToscaPolicyType>builder().name(policyTypeKey.getName()).version(VERSION_001).build());
gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
- assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
- assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));
+ checkEqualsNameDescription(beforePolicyType, gotPolicyType);
List<ToscaPolicyType> gotPolicyTypeList =
new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_001);
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
}
+ private void checkEqualsNameDescription(ToscaPolicyType beforePolicyType, ToscaPolicyType gotPolicyType) {
+ assertEquals(beforePolicyType.getName(), gotPolicyType.getName());
+ assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));
+ }
+
@Test
public void testPolicyTypesCreate() throws Exception {
assertThatThrownBy(() -> {