Repository Test for Experiment Catalog
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/d8cd7ba6 Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/d8cd7ba6 Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/d8cd7ba6 Branch: refs/heads/registry-refactoring Commit: d8cd7ba60ca983f5658f9c405c72501262047c9d Parents: 727dfb7 Author: Abhiit Karanjkar <[email protected]> Authored: Fri Sep 30 10:10:06 2016 -0400 Committer: Abhiit Karanjkar <[email protected]> Committed: Fri Sep 30 10:10:06 2016 -0400 ---------------------------------------------------------------------- .../core/repositories/RepositoryTest.java | 95 +++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/d8cd7ba6/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/RepositoryTest.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/RepositoryTest.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/RepositoryTest.java index 53d77f1..ec1e4a0 100644 --- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/RepositoryTest.java +++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/RepositoryTest.java @@ -56,15 +56,19 @@ public class RepositoryTest { private NotificationRepository notificationRepository; private UserProfileRepository userProfileRepository; private ProjectRepository projectRepository; + private ExperimentRepository experimentRepository; private String gatewayId; private String notificationId; private String userId; private String projectId; + private String experimentId; private final String GATEWAY_DOMAIN = "test1.com"; private final String NOTIFY_MESSAGE = "NotifyMe"; private final String USER_COMMENT = "TestComment"; private final String PROJECT_DESCRIPTION = "Test Description"; + private final String EXPERIMENT_NAME = "sample experiment"; + private final String EXPERIMENT_DESCRIPTION = "sample description"; @Before public void setupRepository() { @@ -74,11 +78,13 @@ public class RepositoryTest { NotificationEntity.class); userProfileRepository = new UserProfileRepository(UserProfile.class, UserProfileEntity.class); projectRepository = new ProjectRepository(Project.class, ProjectEntity.class); + experimentRepository = new ExperimentRepository(ExperimentModel.class, ExperimentEntity.class); gatewayId = "test.com" + System.currentTimeMillis(); notificationId = UUID.randomUUID().toString(); userId = "testuser" + System.currentTimeMillis(); - projectId = "project" + System.currentTimeMillis();; + projectId = "project" + System.currentTimeMillis(); + experimentId = "exp" + System.currentTimeMillis(); } @@ -288,4 +294,91 @@ public class RepositoryTest { } + + @Test + public void experimentRepositoryTest() { + + /* + * Creating Gateway required for UserProfile & Project creation + */ + Gateway gateway = new Gateway(); + gateway.setGatewayApprovalStatus(GatewayApprovalStatus.ACTIVE); + gateway.setGatewayId(gatewayId); + gateway.setDomain(GATEWAY_DOMAIN); + gateway = gatewayRepository.create(gateway); + Assert.assertTrue(!gateway.getGatewayId().isEmpty()); + + /* + * UserProfile Instance creation required for Project Creation + */ + UserProfile userProfile = new UserProfile(); + userProfile.setAiravataInternalUserId(userId); + userProfile.setGatewayId(gateway.getGatewayId()); + userProfile = userProfileRepository.create(userProfile); + Assert.assertTrue(!userProfile.getAiravataInternalUserId().isEmpty()); + + /* + * Project Instance creation + */ + Project project = new Project(); + project.setGatewayId(gatewayId); + project.setOwner(userId); + project.setProjectID(projectId); + project.setGatewayIdIsSet(true); + project = projectRepository.create(project); + Assert.assertTrue(!project.getProjectID().isEmpty()); + + /* + * Experiment Instance Creation + */ + + ExperimentModel experiment = new ExperimentModel(); + experiment.setExperimentId(experimentId); + experiment.setExperimentName(EXPERIMENT_NAME); + experiment.setGatewayId(gatewayId); + experiment.setUserName(userId); + experiment.setProjectId(projectId); + + /* + * Experiment Repository Insert Operation Test + */ + experiment = experimentRepository.create(experiment); + Assert.assertTrue(!experiment.getExperimentId().isEmpty()); + + + + + /* + * Experiment Repository Update Operation Test + */ + experiment.setDescription(EXPERIMENT_DESCRIPTION); + experimentRepository.update(experiment); + experiment = experimentRepository.get(experimentId); + Assert.assertEquals(experiment.getDescription(), EXPERIMENT_DESCRIPTION); + + /* + * Workspace Project Repository Select Operation Test + */ + experiment = null; + experiment = experimentRepository.get(experimentId); + Assert.assertNotNull(experiment); + + /* + * Experiment Repository Delete Operation + */ + + boolean deleteResult = experimentRepository.delete(experimentId); + Assert.assertTrue(deleteResult); + + deleteResult = projectRepository.delete(projectId); + Assert.assertTrue(deleteResult); + + deleteResult = userProfileRepository.delete(userId); + Assert.assertTrue(deleteResult); + + deleteResult = gatewayRepository.delete(gatewayId); + Assert.assertTrue(deleteResult); + + + } } \ No newline at end of file
