Making changes to the tests
MODIFY
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/JPAUtil/WorkflowCatalogJPAUtils.java
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/JPAUtil/WorkflowCatalogJPAUtils.java
@@ -32,16 +32,16 @@ public class WorkflowCatalogJPAUtils {
private final static Logger logger = LoggerFactory.getLogger(WorkflowCatalogJPAUtils.class);
private static final String PERSISTENCE_UNIT_NAME = "workflowcatalog_data";
- private static final String WFCATALOG_JDBC_DRIVER = "wfcatalog.jdbc.driver";
- private static final String WFCATALOG_JDBC_URL = "wfcatalog.jdbc.url";
- private static final String WFCATALOG_JDBC_USER = "wfcatalog.jdbc.user";
- private static final String WFCATALOG_JDBC_PASSWORD = "wfcatalog.jdbc.password";
- private static final String WFCATALOG_VALIDATION_QUERY = "wfcatalog.validationQuery";
+ private static final String WFCATALOG_JDBC_DRIVER = "workflowcatalog.jdbc.driver";
+ private static final String WFCATALOG_JDBC_URL = "workflowcatalog.jdbc.url";
+ private static final String WFCATALOG_JDBC_USER = "workflowcatalog.jdbc.user";
+ private static final String WFCATALOG_JDBC_PASSWORD = "workflowcatalog.jdbc.password";
+ private static final String WFCATALOG_VALIDATION_QUERY = "workflowcatalog.validationQuery";
private static final String JPA_CACHE_SIZE = "jpa.cache.size";
private static final String JPA_CACHE_ENABLED = "cache.enable";
- @PersistenceUnit(unitName="workflowcatalog_data")
+ @PersistenceUnit(unitName=PERSISTENCE_UNIT_NAME)
protected static EntityManagerFactory factory;
- @PersistenceContext(unitName="worlkflowcatalog_data")
+ @PersistenceContext(unitName=PERSISTENCE_UNIT_NAME)
private static EntityManager wfCatEntityManager;
public static EntityManager getEntityManager() throws ApplicationSettingsException {
@@ -52,7 +52,7 @@ public class WorkflowCatalogJPAUtils {
"Password=" + readServerProperties(WFCATALOG_JDBC_PASSWORD) +
",validationQuery=" + readServerProperties(WFCATALOG_VALIDATION_QUERY);
System.out.println(connectionProperties);
- Map<String, String> properties = new HashMap<String, String>();
+ Map<String, String> properties = new HashMap<>();
properties.put("openjpa.ConnectionDriverName", "org.apache.commons.dbcp.BasicDataSource");
properties.put("openjpa.ConnectionProperties", connectionProperties);
properties.put("openjpa.DynamicEnhancementAgent", "true");

MODIFY
modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/replicacatalog/util/Initialize.java
modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/replicacatalog/util/Initialize.java
@@ -200,8 +200,8 @@ public class Initialize {
executeSQL(sql.toString(), conn);
}
}catch (IOException e){
- logger.error("Error occurred while executing SQL script for creating Airavata Data Catalog database", e);
- throw new Exception("Error occurred while executing SQL script for creating Airavata Data Catalog database", e);
+ logger.error("Error occurred while executing SQL script for creating Airavata Replica Catalog database", e);
+ throw new Exception("Error occurred while executing SQL script for creating Airavata Replica Catalog database", e);
}finally {
if (reader != null) {
reader.close();

MODIFY
modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowRepositoryTest.java
modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowRepositoryTest.java
*/
package org.apache.airavata.registry.core.repositories.workflowcatalog;
+import org.apache.airavata.model.WorkflowModel;
+import org.apache.airavata.model.application.io.OutputDataObjectType;
import org.apache.airavata.registry.core.repositories.workflowcatalog.util.Initialize;
import org.apache.airavata.registry.cpi.WorkflowCatalogException;
import org.junit.After;
@@ -27,6 +29,11 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
public class WorkflowRepositoryTest {
private static Initialize initialize;
@@ -53,7 +60,45 @@ public class WorkflowRepositoryTest {
@Test
public void WorkflowRepositoryTest() throws WorkflowCatalogException {
+ WorkflowModel workflowModel1 = new WorkflowModel();
+ workflowModel1.setName("workflow1");
+ String templateId1 = workflowRepository.registerWorkflow(workflowModel1, gatewayId);
+ assertTrue(templateId1 != null);
+
+ workflowModel1.setCreatedUser("user1");
+ workflowRepository.updateWorkflow(templateId1, workflowModel1);
+
+ OutputDataObjectType outputDataObjectType1 = new OutputDataObjectType();
+ outputDataObjectType1.setName("outputKey1");
+ OutputDataObjectType outputDataObjectType2 = new OutputDataObjectType();
+ outputDataObjectType2.setName("outputKey2");
+ List<OutputDataObjectType> outputDataObjectTypeList = new ArrayList<>();
+ outputDataObjectTypeList.add(outputDataObjectType1);
+ outputDataObjectTypeList.add(outputDataObjectType2);
+ workflowRepository.updateWorkflowOutputs(templateId1, outputDataObjectTypeList);
+
+ WorkflowModel retrievedWorkflowModel = workflowRepository.getWorkflow(templateId1);
+ assertEquals(gatewayId, retrievedWorkflowModel.getGatewayId());
+ assertEquals(workflowModel1.getCreatedUser(), retrievedWorkflowModel.getCreatedUser());
+ assertTrue(retrievedWorkflowModel.getWorkflowOutputs().size() == 2);
+
+ WorkflowModel workflowModel2 = new WorkflowModel();
+ workflowModel2.setName("workflow2");
+ String templateId2 = workflowRepository.registerWorkflow(workflowModel2, gatewayId);
+ assertTrue(templateId2 != null);
+
+ List<String> workflows = workflowRepository.getAllWorkflows(gatewayId);
+ assertTrue(workflows.size() == 2);
+
+ String retrievedTemplateId = workflowRepository.getWorkflowTemplateId(workflowModel1.getName());
+ assertEquals(templateId1, retrievedTemplateId);
+
+ assertTrue(workflowRepository.isWorkflowExistWithName(workflowModel2.getName()));
+
+ workflowRepository.deleteWorkflow(templateId1);
+ assertFalse(workflowRepository.isWorkflowExistWithName(workflowModel1.getName()));
+ workflowRepository.deleteWorkflow(templateId2);
}
}

MODIFY
modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/workflowcatalog/util/Initialize.java
modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/workflowcatalog/util/Initialize.java
@@ -36,7 +36,7 @@ import java.sql.*;
import java.util.StringTokenizer;
public class Initialize {
- private static final Logger logger = LoggerFactory.getLogger(org.apache.airavata.registry.core.repositories.workflowcatalog.util.Initialize.class);
+ private static final Logger logger = LoggerFactory.getLogger(Initialize.class);
public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
public String scriptName = "workflowcatalog-derby.sql";
private NetworkServerControl server;
@@ -200,8 +200,8 @@ public class Initialize {
executeSQL(sql.toString(), conn);
}
}catch (IOException e){
- logger.error("Error occurred while executing SQL script for creating Airavata Data Catalog database", e);
- throw new Exception("Error occurred while executing SQL script for creating Airavata Data Catalog database", e);
+ logger.error("Error occurred while executing SQL script for creating Airavata Workflow Catalog database", e);
+ throw new Exception("Error occurred while executing SQL script for creating Airavata Workflow Catalog database", e);
}finally {
if (reader != null) {
reader.close();

Making changes to the tests