Repository Test for Experiment Catalog
@@ -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();
}
@@ -287,5 +293,92 @@ public class RepositoryTest {
Assert.assertTrue(deleteResult);
+ }
+
+ @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
