* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 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 org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.ia.DbAudit;
-import org.onap.policy.common.ia.DbDAO;
+import org.onap.policy.common.ia.DbDao;
import org.onap.policy.common.ia.IntegrityAuditProperties;
import org.onap.policy.common.ia.jpa.IntegrityAuditEntity;
import org.onap.policy.common.im.jpa.ForwardProgressEntity;
public class DbAuditCompareEntriesTest {
private static Log logger = LogFactory.getLog(DbAuditCompareEntriesTest.class);
- private DbDAO dbDAO;
+ private DbDao dbDAO;
private String persistenceUnit;
private Properties properties;
private String resourceName;
persistenceUnit = "testPapPU";
resourceName = "siteA.pap1";
- //Clean the iaTest DB table for IntegrityAuditEntity entries
+ // Clean the iaTest DB table for IntegrityAuditEntity entries
cleanDb(persistenceUnit, properties);
logger.info("setUp: Exiting");
@After
public void tearDown() throws Exception {
logger.info("tearDown: Entering");
- //nothing to do
+ // nothing to do
logger.info("tearDown: Exiting");
}
- public void cleanDb(String persistenceUnit, Properties properties){
+ public void cleanDb(String persistenceUnit, Properties properties) {
logger.debug("cleanDb: enter");
EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
logger.debug("cleanDb: exit");
}
-
/*
* Tests that a comparison between hashsets is successful if
* the entries match
public void runAllTests() throws Exception {
logger.info("runAllTests: Entering");
-
testIntegrityAuditEntity();
testBackupMonitorEntity();
testStateManagementEntity();
testForwardProgressEntity();
testResourceRegistrationEntity();
- //clean up the IntegrityAuditEntity table
+ // clean up the IntegrityAuditEntity table
cleanDb(persistenceUnit, properties);
logger.info("runAllTests: Exit");
}
-
public void testIntegrityAuditEntity() throws Exception {
logger.info("testIntegrityAuditEntity: Entering");
- dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ dbDAO = new DbDao(resourceName, persistenceUnit, properties);
DbAudit dbAudit = new DbAudit(dbDAO);
String className = null;
- //There is only one entry IntegrityAuditEntity, but we will check anyway
+ // There is only one entry IntegrityAuditEntity, but we will check anyway
Set<String> classNameSet = dbDAO.getPersistenceClassNames();
- for(String c : classNameSet){
- if (c.equals("org.onap.policy.common.ia.jpa.IntegrityAuditEntity")){
+ for (String c : classNameSet) {
+ if (c.equals("org.onap.policy.common.ia.jpa.IntegrityAuditEntity")) {
className = c;
}
}
void testBackupMonitorEntity() throws Exception {
logger.info("testBackupMonitorEntity: Entering");
- dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ dbDAO = new DbDao(resourceName, persistenceUnit, properties);
DbAudit dbAudit = new DbAudit(dbDAO);
BackUpMonitorEntity entry1 = new BackUpMonitorEntity();
// Two entries with the same field values
-
entry1.setFlag("flag1");
entry1.setResourceNodeName("node1");
entry1.setResourceName("resourceName");
Set<Object> result = dbAudit.compareEntries(myEntries, theirEntries);
-
// Assert that there are no mismatches returned
assertTrue(result.isEmpty());
-
- /* ************************************
+ /*
+ * ************************************
* Now test with a mis-matched entry
- * ************************************/
-
-
+ ************************************/
// Change a field on entry2
result = dbAudit.compareEntries(myEntries, theirEntries);
-
- //Assert that there was one mismatch
+ // Assert that there was one mismatch
assertEquals(1, result.size());
logger.info("testBackupMonitorEntity: Exit");
void testStateManagementEntity() throws Exception {
logger.info("testStateManagementEntity: Entering");
- dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ dbDAO = new DbDao(resourceName, persistenceUnit, properties);
DbAudit dbAudit = new DbAudit(dbDAO);
StateManagementEntity entry1 = new StateManagementEntity();
Set<Object> result = dbAudit.compareEntries(myEntries, theirEntries);
-
// Assert that there are no mismatches returned
assertTrue(result.isEmpty());
-
- /* ************************************
+ /*
+ * ************************************
* Now test with a mis-matched entry
- * ************************************/
-
-
+ ************************************/
// Change a field on entry2
result = dbAudit.compareEntries(myEntries, theirEntries);
-
- //Assert that there was one mismatch
+ // Assert that there was one mismatch
assertEquals(1, result.size());
logger.info("testStateManagementEntity: Exit");
void testForwardProgressEntity() throws Exception {
logger.info("testForwardProgressEntity: Entering");
- dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ dbDAO = new DbDao(resourceName, persistenceUnit, properties);
DbAudit dbAudit = new DbAudit(dbDAO);
ForwardProgressEntity entry1 = new ForwardProgressEntity();
Set<Object> result = dbAudit.compareEntries(myEntries, theirEntries);
-
// Assert that there are no mismatches returned
assertTrue(result.isEmpty());
-
- /* ************************************
+ /*
+ * ************************************
* Now test with a mis-matched entry
- * ************************************/
+ ************************************/
// Change a field on entry2
result = dbAudit.compareEntries(myEntries, theirEntries);
-
- //Assert that there was one mismatch
+ // Assert that there was one mismatch
assertEquals(1, result.size());
logger.info("testForwardProgressEntity: Exit");
void testResourceRegistrationEntity() throws Exception {
logger.info("testResourceRegistrationEntity: Entering");
- dbDAO = new DbDAO(resourceName, persistenceUnit, properties);
+ dbDAO = new DbDao(resourceName, persistenceUnit, properties);
DbAudit dbAudit = new DbAudit(dbDAO);
ResourceRegistrationEntity entry1 = new ResourceRegistrationEntity();
Set<Object> result = dbAudit.compareEntries(myEntries, theirEntries);
-
// Assert that there are no mismatches returned
assertTrue(result.isEmpty());
-
- /* ************************************
+ /*
+ * ************************************
* Now test with a mis-matched entry
- * ************************************/
+ ************************************/
// Change a field on entry2
result = dbAudit.compareEntries(myEntries, theirEntries);
-
- //Assert that there was one mismatch
+ // Assert that there was one mismatch
assertEquals(1, result.size());
logger.info("testResourceRegistrationEntity: Exit");
}
-}
\ No newline at end of file
+}