airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata] 02/02: AIRAVATA-2821 Setting status id in Process, Job Repositories
Date Mon, 11 Jun 2018 16:39:43 GMT
This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch group-based-auth
in repository https://gitbox.apache.org/repos/asf/airavata.git

commit ff0c734c6c41a59beb8f354826e2bd7bd9b08ab9
Author: Marcus Christie <machristie@apache.org>
AuthorDate: Mon Jun 11 12:36:24 2018 -0400

    AIRAVATA-2821 Setting status id in Process, Job Repositories
    
    Also changed the order of implicit field initialization in save methods
    so that model fields are updated first, then models are mapped to entity
    classes, then entity fields (mostly primary key fields) are updated
    last. This keeps the model fields up to date with what is persisted and
    fixes the problem of creating a duplicate status if an experiment is
    saved and then updated.
---
 .../expcatalog/ExperimentRepository.java           | 40 +++++++++++---------
 .../repositories/expcatalog/JobRepository.java     | 22 ++++++++---
 .../expcatalog/JobStatusRepository.java            |  2 +-
 .../repositories/expcatalog/ProcessRepository.java | 38 ++++++++++++-------
 .../expcatalog/ProcessStatusRepository.java        |  2 +-
 .../repositories/expcatalog/TaskRepository.java    | 44 +++++++++++++---------
 .../expcatalog/ExperimentRepositoryTest.java       |  8 ++--
 .../repositories/expcatalog/JobRepositoryTest.java | 11 +++++-
 .../expcatalog/ProcessRepositoryTest.java          | 22 +++++++----
 .../expcatalog/TaskRepositoryTest.java             |  7 ++--
 10 files changed, 121 insertions(+), 75 deletions(-)

diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepository.java
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepository.java
index 3016787..8465404 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepository.java
@@ -37,7 +37,6 @@ import org.dozer.Mapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -60,8 +59,28 @@ public class ExperimentRepository extends ExpCatAbstractRepository<ExperimentMod
             logger.debug("Setting the Experiment's ExperimentId");
             experimentModel.setExperimentId(ExpCatalogUtils.getID(experimentModel.getExperimentName()));
         }
-
         String experimentId = experimentModel.getExperimentId();
+
+        if (experimentModel.getExperimentStatus() != null) {
+            logger.debug("Populating the status id of ExperimentStatus objects for the Experiment");
+            experimentModel.getExperimentStatus().forEach(experimentStatusEntity -> {
+                if (experimentStatusEntity.getStatusId() == null) {
+                    experimentStatusEntity.setStatusId(AiravataUtils.getId("EXPERIMENT_STATE"));
+                }
+            });
+        }
+
+        if (experimentModel.getProcesses() != null) {
+            logger.debug("Populating the Process objects' Experiment ID for the Experiment");
+            experimentModel.getProcesses().forEach(processModel -> processModel.setExperimentId(experimentId));
+        }
+
+        if (!isExperimentExist(experimentId)) {
+            logger.debug("Populating creation time if it doesn't already exist");
+            experimentModel.setCreationTime(System.currentTimeMillis());
+        }
+
+
         Mapper mapper = ObjectMapperSingleton.getInstance();
         ExperimentEntity experimentEntity = mapper.map(experimentModel, ExperimentEntity.class);
 
@@ -82,12 +101,7 @@ public class ExperimentRepository extends ExpCatAbstractRepository<ExperimentMod
 
         if (experimentEntity.getExperimentStatus() != null) {
             logger.debug("Populating the Primary Key of ExperimentStatus objects for the
Experiment");
-            experimentEntity.getExperimentStatus().forEach(experimentStatusEntity -> {
-                if (experimentStatusEntity.getStatusId() == null) {
-                    experimentStatusEntity.setStatusId(AiravataUtils.getId("EXPERIMENT_STATE"));
-                }
-                experimentStatusEntity.setExperimentId(experimentId);
-            });
+            experimentEntity.getExperimentStatus().forEach(experimentStatusEntity -> experimentStatusEntity.setExperimentId(experimentId));
         }
 
         if (experimentEntity.getErrors() != null) {
@@ -95,16 +109,6 @@ public class ExperimentRepository extends ExpCatAbstractRepository<ExperimentMod
             experimentEntity.getErrors().forEach(experimentErrorEntity -> experimentErrorEntity.setExperimentId(experimentId));
         }
 
-        if (experimentEntity.getProcesses() != null) {
-            logger.debug("Populating the Process objects' Experiment ID for the Experiment");
-            experimentEntity.getProcesses().forEach(processEntity -> processEntity.setExperimentId(experimentId));
-        }
-
-        if (!isExperimentExist(experimentId)) {
-            logger.debug("Checking if the Experiment already exists");
-            experimentEntity.setCreationTime(new Timestamp((System.currentTimeMillis())));
-        }
-
         return execute(entityManager -> entityManager.merge(experimentEntity));
     }
 
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/JobRepository.java
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/JobRepository.java
index f759bf4..25af655 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/JobRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/JobRepository.java
@@ -25,6 +25,7 @@ import org.apache.airavata.model.job.JobModel;
 import org.apache.airavata.registry.core.entities.expcatalog.JobEntity;
 import org.apache.airavata.registry.core.entities.expcatalog.JobPK;
 import org.apache.airavata.registry.core.utils.DBConstants;
+import org.apache.airavata.registry.core.utils.ExpCatalogUtils;
 import org.apache.airavata.registry.core.utils.ObjectMapperSingleton;
 import org.apache.airavata.registry.core.utils.QueryConstants;
 import org.apache.airavata.registry.cpi.RegistryException;
@@ -32,7 +33,6 @@ import org.dozer.Mapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -54,6 +54,21 @@ public class JobRepository extends ExpCatAbstractRepository<JobModel,
JobEntity,
             jobModel.setJobId(jobPK.getJobId());
         }
 
+        if (jobModel.getJobStatuses() != null) {
+            logger.debug("Populating the status ids of JobStatus objects for the Job");
+            jobModel.getJobStatuses().forEach(jobStatus -> {
+                if (jobStatus.getStatusId() == null) {
+                    jobStatus.setStatusId(ExpCatalogUtils.getID("JOB_STATE"));
+                }
+            });
+        }
+
+        if (!isJobExist(jobPK)) {
+            logger.debug("Setting creation time to current time if does not exist");
+            jobModel.setCreationTime(System.currentTimeMillis());
+        }
+
+
         String jobId = jobPK.getJobId();
         String taskId = jobPK.getTaskId();
         Mapper mapper = ObjectMapperSingleton.getInstance();
@@ -67,11 +82,6 @@ public class JobRepository extends ExpCatAbstractRepository<JobModel,
JobEntity,
             });
         }
 
-        if (!isJobExist(jobPK)) {
-            logger.debug("Checking if the Job already exists");
-            jobEntity.setCreationTime(new Timestamp((System.currentTimeMillis())));
-        }
-
         return execute(entityManager -> entityManager.merge(jobEntity));
     }
 
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/JobStatusRepository.java
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/JobStatusRepository.java
index 6ad2acb..fad244d 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/JobStatusRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/JobStatusRepository.java
@@ -63,7 +63,7 @@ public class JobStatusRepository extends ExpCatAbstractRepository<JobStatus,
Job
 
         if (jobStatus.getStatusId() == null) {
             logger.debug("Setting the JobStatusEntity's StatusId");
-            jobStatus.setStatusId(ExpCatalogUtils.getID("STATUS"));
+            jobStatus.setStatusId(ExpCatalogUtils.getID("JOB_STATE"));
         }
 
         return saveJobStatus(jobStatus, jobPK);
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessRepository.java
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessRepository.java
index 2fde4ea..9679810 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessRepository.java
@@ -33,8 +33,10 @@ import org.dozer.Mapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.sql.Timestamp;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 public class ProcessRepository extends ExpCatAbstractRepository<ProcessModel, ProcessEntity,
String> {
     private final static Logger logger = LoggerFactory.getLogger(ProcessRepository.class);
@@ -53,6 +55,27 @@ public class ProcessRepository extends ExpCatAbstractRepository<ProcessModel,
Pr
         }
 
         String processId = processModel.getProcessId();
+
+        if (processModel.getProcessStatuses() != null) {
+            logger.debug("Populating the status id of ProcessStatus objects for the Process");
+            processModel.getProcessStatuses().forEach(processStatusEntity -> {
+                if (processStatusEntity.getStatusId() == null) {
+                    processStatusEntity.setStatusId(ExpCatalogUtils.getID("PROCESS_STATE"));
+                }
+            });
+        }
+
+        if (processModel.getTasks() != null) {
+            logger.debug("Populating the parent process id of Tasks for the Process");
+            processModel.getTasks().forEach(taskEntity -> taskEntity.setParentProcessId(processId));
+        }
+
+        if (!isProcessExist(processId)) {
+            logger.debug("Setting creation time if process doesn't already exist");
+            processModel.setCreationTime(System.currentTimeMillis());
+        }
+        processModel.setLastUpdateTime(System.currentTimeMillis());
+
         Mapper mapper = ObjectMapperSingleton.getInstance();
         ProcessEntity processEntity = mapper.map(processModel, ProcessEntity.class);
 
@@ -81,17 +104,6 @@ public class ProcessRepository extends ExpCatAbstractRepository<ProcessModel,
Pr
             processEntity.getProcessErrors().forEach(processErrorEntity -> processErrorEntity.setProcessId(processId));
         }
 
-        if (processEntity.getTasks() != null) {
-            logger.debug("Populating the Process objects' Process ID for the Process");
-            processEntity.getTasks().forEach(taskEntity -> taskEntity.setParentProcessId(processId));
-        }
-
-        if (!isProcessExist(processId)) {
-            logger.debug("Checking if the Process already exists");
-            processEntity.setCreationTime(new Timestamp((System.currentTimeMillis())));
-        }
-
-        processEntity.setLastUpdateTime(new Timestamp((System.currentTimeMillis())));
         return execute(entityManager -> entityManager.merge(processEntity));
     }
 
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessStatusRepository.java
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessStatusRepository.java
index 2ed71d0..6887a99 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessStatusRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessStatusRepository.java
@@ -57,7 +57,7 @@ public class ProcessStatusRepository extends ExpCatAbstractRepository<ProcessSta
 
         if (processStatus.getStatusId() == null) {
             logger.debug("Setting the ProcessStatus's StatusId");
-            processStatus.setStatusId(ExpCatalogUtils.getID("STATUS"));
+            processStatus.setStatusId(ExpCatalogUtils.getID("PROCESS_STATE"));
         }
 
         return saveProcessStatus(processStatus, processId);
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/TaskRepository.java
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/TaskRepository.java
index c117da7..040f923 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/TaskRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/TaskRepository.java
@@ -32,8 +32,10 @@ import org.dozer.Mapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.sql.Timestamp;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 public class TaskRepository extends ExpCatAbstractRepository<TaskModel, TaskEntity, String>
{
     private final static Logger logger = LoggerFactory.getLogger(TaskRepository.class);
@@ -52,35 +54,41 @@ public class TaskRepository extends ExpCatAbstractRepository<TaskModel,
TaskEnti
         }
 
         String taskId = taskModel.getTaskId();
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        TaskEntity taskEntity = mapper.map(taskModel, TaskEntity.class);
 
-        if (taskEntity.getTaskStatuses() != null) {
-            logger.debug("Populating the Primary Key of TaskStatus objects for the Task");
-            taskEntity.getTaskStatuses().forEach(taskStatusEntity -> {
+        if (taskModel.getJobs() != null) {
+            logger.debug("Populating the Job objects' Task ID for the Task");
+            taskModel.getJobs().forEach(jobEntity -> jobEntity.setTaskId(taskId));
+        }
+
+        if (taskModel.getTaskStatuses() != null) {
+            logger.debug("Populating the status id of TaskStatus objects for the Task");
+            taskModel.getTaskStatuses().forEach(taskStatusEntity -> {
                 if (taskStatusEntity.getStatusId() == null) {
                     taskStatusEntity.setStatusId(ExpCatalogUtils.getID("TASK_STATE"));
                 }
-                taskStatusEntity.setTaskId(taskId);
             });
         }
 
-        if (taskEntity.getTaskErrors() != null) {
-            logger.debug("Populating the Primary Key of TaskError objects for the Task");
-            taskEntity.getTaskErrors().forEach(taskErrorEntity -> taskErrorEntity.setTaskId(taskId));
+        if (!isTaskExist(taskId)) {
+            logger.debug("Setting creation time if Task doesn't already exist");
+            taskModel.setCreationTime(System.currentTimeMillis());
         }
 
-        if (taskEntity.getJobs() != null) {
-            logger.debug("Populating the Job objects' Task ID for the Task");
-            taskEntity.getJobs().forEach(jobEntity -> jobEntity.setTaskId(taskId));
+        taskModel.setLastUpdateTime(System.currentTimeMillis());
+
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        TaskEntity taskEntity = mapper.map(taskModel, TaskEntity.class);
+
+        if (taskEntity.getTaskStatuses() != null) {
+            logger.debug("Populating the Primary Key of TaskStatus objects for the Task");
+            taskEntity.getTaskStatuses().forEach(taskStatusEntity -> taskStatusEntity.setTaskId(taskId));
         }
 
-        if (!isTaskExist(taskId)) {
-            logger.debug("Checking if the Task already exists");
-            taskEntity.setCreationTime(new Timestamp((System.currentTimeMillis())));
+        if (taskEntity.getTaskErrors() != null) {
+            logger.debug("Populating the Primary Key of TaskError objects for the Task");
+            taskEntity.getTaskErrors().forEach(taskErrorEntity -> taskErrorEntity.setTaskId(taskId));
         }
 
-        taskEntity.setLastUpdateTime(new Timestamp((System.currentTimeMillis())));
         return execute(entityManager -> entityManager.merge(taskEntity));
     }
 
diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepositoryTest.java
b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepositoryTest.java
index 9dff2b3..1f9844a 100644
--- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepositoryTest.java
+++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepositoryTest.java
@@ -93,12 +93,10 @@ public class ExperimentRepositoryTest {
         String experimentId = experimentRepository.addExperiment(experimentModel);
         assertTrue(experimentId != null);
 
-        // Retrieve the experiment again to get ids populated on ExperimentStatus instances
-        ExperimentModel retrievedExperimentModel = experimentRepository.getExperiment(experimentId);
-        retrievedExperimentModel.setDescription("description");
-        experimentRepository.updateExperiment(retrievedExperimentModel, experimentId);
+        experimentModel.setDescription("description");
+        experimentRepository.updateExperiment(experimentModel, experimentId);
 
-        retrievedExperimentModel = experimentRepository.getExperiment(experimentId);
+        ExperimentModel retrievedExperimentModel = experimentRepository.getExperiment(experimentId);
         assertEquals("description", retrievedExperimentModel.getDescription());
         assertEquals(ExperimentType.SINGLE_APPLICATION, retrievedExperimentModel.getExperimentType());
         assertEquals("gateway-instance-id", retrievedExperimentModel.getGatewayInstanceId());
diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/JobRepositoryTest.java
b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/JobRepositoryTest.java
index 203ef7e..9a6f7c1 100644
--- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/JobRepositoryTest.java
+++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/JobRepositoryTest.java
@@ -24,6 +24,8 @@ import org.apache.airavata.model.experiment.ExperimentModel;
 import org.apache.airavata.model.experiment.ExperimentType;
 import org.apache.airavata.model.job.JobModel;
 import org.apache.airavata.model.process.ProcessModel;
+import org.apache.airavata.model.status.JobState;
+import org.apache.airavata.model.status.JobStatus;
 import org.apache.airavata.model.task.TaskModel;
 import org.apache.airavata.model.task.TaskTypes;
 import org.apache.airavata.model.workspace.Gateway;
@@ -118,6 +120,9 @@ public class JobRepositoryTest {
         jobModel.setTaskId(taskId);
         jobModel.setJobDescription("jobDescription");
 
+        JobStatus jobStatus = new JobStatus(JobState.SUBMITTED);
+        jobModel.addToJobStatuses(jobStatus);
+
         String jobId = jobRepository.addJob(jobModel, processId);
         assertTrue(jobId != null);
         assertTrue(taskRepository.getTask(taskId).getJobs().size() == 1);
@@ -128,7 +133,11 @@ public class JobRepositoryTest {
 
         jobModel.setJobName("jobName");
         jobRepository.updateJob(jobModel, jobPK);
-        assertEquals("jobName", jobRepository.getJob(jobPK).getJobName());
+        final JobModel retrievedJob = jobRepository.getJob(jobPK);
+        assertEquals("jobName", retrievedJob.getJobName());
+        assertEquals(1, retrievedJob.getJobStatusesSize());
+        assertEquals(JobState.SUBMITTED, retrievedJob.getJobStatuses().get(0).getJobState());
+
 
         List<String> jobIdList = jobRepository.getJobIds(DBConstants.Job.TASK_ID, taskId);
         assertTrue(jobIdList.size() == 1);
diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessRepositoryTest.java
b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessRepositoryTest.java
index 1525515..b7da06f 100644
--- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessRepositoryTest.java
+++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessRepositoryTest.java
@@ -24,11 +24,13 @@ import org.apache.airavata.model.experiment.ExperimentModel;
 import org.apache.airavata.model.experiment.ExperimentType;
 import org.apache.airavata.model.process.ProcessModel;
 import org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel;
+import org.apache.airavata.model.status.ProcessState;
+import org.apache.airavata.model.status.ProcessStatus;
 import org.apache.airavata.model.workspace.Gateway;
 import org.apache.airavata.model.workspace.Project;
+import org.apache.airavata.registry.core.repositories.expcatalog.util.Initialize;
 import org.apache.airavata.registry.core.utils.DBConstants;
 import org.apache.airavata.registry.cpi.RegistryException;
-import org.apache.airavata.registry.core.repositories.expcatalog.util.Initialize;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -36,9 +38,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
+
+import static org.junit.Assert.*;
 
 public class ProcessRepositoryTest {
 
@@ -94,6 +95,9 @@ public class ProcessRepositoryTest {
         String experimentId = experimentRepository.addExperiment(experimentModel);
 
         ProcessModel processModel = new ProcessModel(null, experimentId);
+        ProcessStatus processStatus = new ProcessStatus();
+        processStatus.setState(ProcessState.CREATED);
+        processModel.addToProcessStatuses(processStatus);
         String processId = processRepository.addProcess(processModel, experimentId);
         assertTrue(processId != null);
         assertTrue(experimentRepository.getExperiment(experimentId).getProcesses().size()
== 1);
@@ -102,10 +106,12 @@ public class ProcessRepositoryTest {
         processModel.setUseUserCRPref(true);
         processRepository.updateProcess(processModel, processId);
 
-        ProcessModel retrievedProcessModel = processRepository.getProcess(processId);
-        assertEquals(experimentId, retrievedProcessModel.getExperimentId());
-        assertEquals("detail", retrievedProcessModel.getProcessDetail());
-        assertTrue(retrievedProcessModel.isUseUserCRPref());
+        ProcessModel retrievedProcess = processRepository.getProcess(processId);
+        assertEquals(experimentId, retrievedProcess.getExperimentId());
+        assertEquals("detail", retrievedProcess.getProcessDetail());
+        assertTrue(retrievedProcess.isUseUserCRPref());
+        assertEquals(1, retrievedProcess.getProcessStatusesSize());
+        assertEquals(ProcessState.CREATED, retrievedProcess.getProcessStatuses().get(0).getState());
 
         ComputationalResourceSchedulingModel computationalResourceSchedulingModel = new ComputationalResourceSchedulingModel();
         assertEquals(processId, processRepository.addProcessResourceSchedule(computationalResourceSchedulingModel,
processId));
diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/TaskRepositoryTest.java
b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/TaskRepositoryTest.java
index 4da9ee1..04907a8 100644
--- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/TaskRepositoryTest.java
+++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/TaskRepositoryTest.java
@@ -113,12 +113,11 @@ public class TaskRepositoryTest {
 
         String taskId = taskRepository.addTask(taskModel, processId);
         assertTrue(taskId != null);
-        // Retrieve task to get its automatically populated status id
-        final TaskModel retrievedTask = taskRepository.getTask(taskId);
         assertTrue(processRepository.getProcess(processId).getTasks().size() == 1);
 
-        retrievedTask.setTaskType(TaskTypes.MONITORING);
-        taskRepository.updateTask(retrievedTask, taskId);
+        taskModel.setTaskType(TaskTypes.MONITORING);
+        taskRepository.updateTask(taskModel, taskId);
+        TaskModel retrievedTask = taskRepository.getTask(taskId);
         assertEquals(TaskTypes.MONITORING, retrievedTask.getTaskType());
         assertArrayEquals("subtask model".getBytes(StandardCharsets.UTF_8), retrievedTask.getSubTaskModel());
         assertEquals(1, retrievedTask.getTaskStatusesSize());

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.

Mime
View raw message