Repository: airavata Updated Branches: refs/heads/registry-refactoring 42cb597e5 -> 1d96b11ee
http://git-wip-us.apache.org/repos/asf/airavata/blob/1d96b11e/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowRepository.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowRepository.java index 2547631..b702342 100644 --- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowRepository.java +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowRepository.java @@ -1,3 +1,23 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ package org.apache.airavata.registry.core.repositories.workflowcatalog; import org.apache.airavata.model.WorkflowModel; @@ -6,9 +26,6 @@ import org.apache.airavata.registry.core.repositories.AbstractRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * Created by abhijit on 9/28/2016. - */ public class WorkflowRepository extends AbstractRepository<WorkflowModel, WorkflowEntity, String> { private final static Logger logger = LoggerFactory.getLogger(WorkflowRepository.class); http://git-wip-us.apache.org/repos/asf/airavata/blob/1d96b11e/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowStatusRepository.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowStatusRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowStatusRepository.java index a0a9468..d4c434b 100644 --- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowStatusRepository.java +++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/workflowcatalog/WorkflowStatusRepository.java @@ -1,3 +1,23 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ package org.apache.airavata.registry.core.repositories.workflowcatalog; import org.apache.airavata.model.WorkflowStatus; @@ -7,9 +27,6 @@ import org.apache.airavata.registry.core.repositories.AbstractRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * Created by abhijit on 9/28/2016. - */ public class WorkflowStatusRepository extends AbstractRepository<WorkflowStatus, WorkflowStatusEntity, WorkflowStatusPK> { private final static Logger logger = LoggerFactory.getLogger(WorkflowStatusRepository.class); http://git-wip-us.apache.org/repos/asf/airavata/blob/1d96b11e/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ExperimentRepositoryTest.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ExperimentRepositoryTest.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ExperimentRepositoryTest.java new file mode 100644 index 0000000..abfaed8 --- /dev/null +++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ExperimentRepositoryTest.java @@ -0,0 +1,157 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.registry.core.repositories; + +import org.apache.airavata.model.experiment.ExperimentModel; +import org.apache.airavata.model.user.UserProfile; +import org.apache.airavata.model.workspace.Gateway; +import org.apache.airavata.model.workspace.GatewayApprovalStatus; +import org.apache.airavata.model.workspace.Project; +import org.apache.airavata.registry.core.entities.expcatalog.ExperimentEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.ProjectEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity; +import org.apache.airavata.registry.core.repositories.expcatalog.ExperimentRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.GatewayRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.ProjectRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.UserProfileRepository; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExperimentRepositoryTest { + private final static Logger logger = LoggerFactory.getLogger(ExperimentRepositoryTest.class); + + private GatewayRepository gatewayRepository; + private UserProfileRepository userProfileRepository; + private ProjectRepository projectRepository; + private ExperimentRepository experimentRepository; + private String gatewayId; + private String userId; + private String projectId; + private String experimentId; + + private final String GATEWAY_DOMAIN = "test1.com"; + private final String EXPERIMENT_NAME = "sample experiment"; + private final String EXPERIMENT_DESCRIPTION = "sample description"; + + + @Before + public void setupRepository() { + + gatewayRepository = new GatewayRepository(Gateway.class, GatewayEntity.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(); + userId = "testuser" + System.currentTimeMillis(); + projectId = "project" + System.currentTimeMillis(); + experimentId = "exp" + System.currentTimeMillis(); + } + + @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 = 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 http://git-wip-us.apache.org/repos/asf/airavata/blob/1d96b11e/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ReplicaCatalogRepositoryTest.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ReplicaCatalogRepositoryTest.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ReplicaCatalogRepositoryTest.java index 8fa515b..38cb722 100644 --- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ReplicaCatalogRepositoryTest.java +++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/ReplicaCatalogRepositoryTest.java @@ -1,36 +1,39 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ package org.apache.airavata.registry.core.repositories; -import org.apache.airavata.model.WorkflowModel; import org.apache.airavata.model.data.replica.DataProductModel; -import org.apache.airavata.model.experiment.ExperimentModel; import org.apache.airavata.model.user.UserProfile; import org.apache.airavata.model.workspace.Gateway; import org.apache.airavata.model.workspace.GatewayApprovalStatus; -import org.apache.airavata.model.workspace.Notification; -import org.apache.airavata.model.workspace.Project; -import org.apache.airavata.registry.core.entities.expcatalog.ExperimentEntity; import org.apache.airavata.registry.core.entities.replicacatalog.DataProductEntity; -import org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowEntity; import org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity; -import org.apache.airavata.registry.core.entities.workspacecatalog.NotificationEntity; -import org.apache.airavata.registry.core.entities.workspacecatalog.ProjectEntity; import org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity; -import org.apache.airavata.registry.core.repositories.expcatalog.ExperimentRepository; import org.apache.airavata.registry.core.repositories.replicacatalog.DataProductRepository; -import org.apache.airavata.registry.core.repositories.workflowcatalog.WorkflowRepository; import org.apache.airavata.registry.core.repositories.workspacecatalog.GatewayRepository; -import org.apache.airavata.registry.core.repositories.workspacecatalog.NotificationRepository; -import org.apache.airavata.registry.core.repositories.workspacecatalog.ProjectRepository; import org.apache.airavata.registry.core.repositories.workspacecatalog.UserProfileRepository; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.util.UUID; - -/** - * Created by abhij on 10/14/2016. - */ public class ReplicaCatalogRepositoryTest { private GatewayRepository gatewayRepository; @@ -39,8 +42,6 @@ public class ReplicaCatalogRepositoryTest { private String userId; private String dataProductUri; - private final String NOTIFY_MESSAGE = "NotifyMe"; - private final String USER_COMMENT = "TestComment"; private final String GATEWAY_DOMAIN = "test1.com"; private final String DATA_PRODUCT_DESCRIPTION = "testDesc"; @@ -110,7 +111,6 @@ public class ReplicaCatalogRepositoryTest { /* * Data Product Repository Select Operation Test */ - dataProduct = null; dataProduct = dataProductRepository.get(dataProductUri); Assert.assertNotNull(dataProduct); http://git-wip-us.apache.org/repos/asf/airavata/blob/1d96b11e/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 deleted file mode 100644 index bc61bbb..0000000 --- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/RepositoryTest.java +++ /dev/null @@ -1,469 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.registry.core.repositories; - -import org.apache.airavata.model.WorkflowModel; -import org.apache.airavata.model.experiment.ExperimentModel; -import org.apache.airavata.model.experiment.UserConfigurationDataModel; -import org.apache.airavata.model.user.NSFDemographics; -import org.apache.airavata.model.user.UserProfile; -import org.apache.airavata.model.workspace.Gateway; -import org.apache.airavata.model.workspace.GatewayApprovalStatus; -import org.apache.airavata.model.workspace.Notification; -import org.apache.airavata.model.workspace.Project; -import org.apache.airavata.registry.core.entities.expcatalog.ExperimentEntity; -import org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowEntity; -import org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity; -import org.apache.airavata.registry.core.entities.workspacecatalog.NotificationEntity; -import org.apache.airavata.registry.core.entities.workspacecatalog.ProjectEntity; -import org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity; -import org.apache.airavata.registry.core.repositories.expcatalog.ExperimentRepository; -import org.apache.airavata.registry.core.repositories.workflowcatalog.WorkflowRepository; -import org.apache.airavata.registry.core.repositories.workspacecatalog.GatewayRepository; -import org.apache.airavata.registry.core.repositories.workspacecatalog.NotificationRepository; -import org.apache.airavata.registry.core.repositories.workspacecatalog.ProjectRepository; -import org.apache.airavata.registry.core.repositories.workspacecatalog.UserProfileRepository; -import org.apache.airavata.registry.core.utils.ObjectMapperSingleton; -import org.dozer.Mapper; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.UUID; - -public class RepositoryTest { - private final static Logger logger = LoggerFactory.getLogger(RepositoryTest.class); - - private GatewayRepository gatewayRepository; - private NotificationRepository notificationRepository; - private UserProfileRepository userProfileRepository; - private ProjectRepository projectRepository; - private ExperimentRepository experimentRepository; - private WorkflowRepository workflowRepository; - private String gatewayId; - private String notificationId; - private String userId; - private String projectId; - private String experimentId; - private String templateId; - - 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"; - private final String WORKFLOW_NAME = "test Workflow"; - - - @Before - public void setupRepository() { - - gatewayRepository = new GatewayRepository(Gateway.class, GatewayEntity.class); - notificationRepository = new NotificationRepository(Notification.class, - NotificationEntity.class); - userProfileRepository = new UserProfileRepository(UserProfile.class, UserProfileEntity.class); - projectRepository = new ProjectRepository(Project.class, ProjectEntity.class); - experimentRepository = new ExperimentRepository(ExperimentModel.class, ExperimentEntity.class); - workflowRepository = new WorkflowRepository(WorkflowModel.class, WorkflowEntity.class); - - gatewayId = "test.com" + System.currentTimeMillis(); - notificationId = UUID.randomUUID().toString(); - userId = "testuser" + System.currentTimeMillis(); - projectId = "project" + System.currentTimeMillis(); - experimentId = "exp" + System.currentTimeMillis(); - templateId = "templateId" + System.currentTimeMillis(); - } - - - @Test - public void gateWayRepositoryTest() { - Gateway gateway = new Gateway(); - gateway.setGatewayApprovalStatus(GatewayApprovalStatus.ACTIVE); - gateway.setGatewayId(gatewayId); - - /* - * GateWay Repository Insert Operation Test - */ - gateway = gatewayRepository.create(gateway); - Assert.assertTrue(!gateway.getGatewayId().isEmpty()); - - /* - * GateWay Repository Update Operation Test - */ - gateway.setDomain(GATEWAY_DOMAIN); - gatewayRepository.update(gateway); - gateway = gatewayRepository.get(gateway.getGatewayId()); - Assert.assertEquals(gateway.getDomain(), GATEWAY_DOMAIN); - - /* - * GateWay Repository Select Operation Test - */ - gateway = null; - gateway = gatewayRepository.get(gatewayId); - Assert.assertNotNull(gateway); - - /* - * GateWay Repository Delete Operation - */ - boolean deleteResult = gatewayRepository.delete(gatewayId); - Assert.assertTrue(deleteResult); - - } - - @Test - public void notificationRepositoryTest() { - - String tempNotificationId = null; - Gateway gateway = new Gateway(); - gateway.setGatewayApprovalStatus(GatewayApprovalStatus.ACTIVE); - gateway.setGatewayId(gatewayId); - gateway.setDomain(GATEWAY_DOMAIN); - gateway = gatewayRepository.create(gateway); - - Notification notification = new Notification(); - notification.setGatewayId(gateway.getGatewayId()); - notification.setNotificationId(notificationId); - - /* - * Notification INSERT Operation Test - */ - notification = notificationRepository.create(notification); - Assert.assertTrue(!notification.getNotificationId().isEmpty()); - - /* - * Notification SELECT Operation Test - */ - tempNotificationId = notification.getNotificationId(); - notification = null; - notification = notificationRepository.get(tempNotificationId); - Assert.assertNotNull(notification); - - - /* - * Notification UPDATE Operation Test - */ - notification.setNotificationMessage(NOTIFY_MESSAGE); - notificationRepository.update(notification); - notification = notificationRepository.get(notification.getNotificationId()); - Assert.assertEquals(NOTIFY_MESSAGE, notification.getNotificationMessage()); - - /* - * Notification DELETE Operation Test - */ - boolean result = notificationRepository.delete(tempNotificationId); - Assert.assertTrue(result); - - gatewayRepository.delete(gatewayId); - } - - @Test - public void userProfileRepositoryTest() { - - /* - * Creating Gateway required for UserProfile 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 - */ - UserProfile userProfile = new UserProfile(); - userProfile.setAiravataInternalUserId(userId); - userProfile.setGatewayId(gateway.getGatewayId()); - - /* - * Workspace UserProfile Repository Insert Operation Test - */ - userProfile = userProfileRepository.create(userProfile); - Assert.assertTrue(!userProfile.getAiravataInternalUserId().isEmpty()); - - /* - * Workspace UserProfile Repository Update Operation Test - */ - userProfile.setComments(USER_COMMENT); - userProfileRepository.update(userProfile); - userProfile = userProfileRepository.get(userId); - System.out.println(userProfile.getComments()); - Assert.assertEquals(userProfile.getComments(), USER_COMMENT); - - /* - * Workspace UserProfile Repository Select Operation Test - */ - userProfile = null; - userProfile = userProfileRepository.get(userId); - Assert.assertNotNull(userProfile); - - /* - * Workspace UserProfile Repository Delete Operation - */ - boolean deleteResult = userProfileRepository.delete(userId); - Assert.assertTrue(deleteResult); - deleteResult = gatewayRepository.delete(gatewayId); - Assert.assertTrue(deleteResult); - - - } - - @Test - public void projectRepositoryTest() { - - /* - * 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); - - - - /* - * Workspace Project Repository Insert Operation Test - */ - project = projectRepository.create(project); - Assert.assertTrue(!project.getProjectID().isEmpty()); - - - - /* - * Workspace Project Repository Update Operation Test - */ - project.setDescription(PROJECT_DESCRIPTION); - projectRepository.update(project); - project = projectRepository.get(projectId); - Assert.assertEquals(project.getDescription(), PROJECT_DESCRIPTION); - - /* - * Workspace Project Repository Select Operation Test - */ - project = null; - project = projectRepository.get(projectId); - Assert.assertNotNull(project); - - /* - * Workspace Project Repository Delete Operation - */ - boolean deleteResult = projectRepository.delete(projectId); - Assert.assertTrue(deleteResult); - - deleteResult = userProfileRepository.delete(userId); - Assert.assertTrue(deleteResult); - - deleteResult = gatewayRepository.delete(gatewayId); - 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); - - - } - - - @Test - public void workflowRepositoryTest() { - - - System.out.println(); - /* - * Creating Gateway required for UserProfile & Workflow 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 Workflow Creation - */ - UserProfile userProfile = new UserProfile(); - userProfile.setAiravataInternalUserId(userId); - userProfile.setGatewayId(gateway.getGatewayId()); - userProfile = userProfileRepository.create(userProfile); - Assert.assertTrue(!userProfile.getAiravataInternalUserId().isEmpty()); - - /* - * Workflow Instance Creation - */ - - WorkflowModel workflowModel = new WorkflowModel(); - workflowModel.setTemplateId(templateId); - workflowModel.setCreatedUser(userId); - workflowModel.setGatewayId(gatewayId); - workflowModel.setName(WORKFLOW_NAME); - - - /* - * Workflow Repository Insert Operation Test - */ - workflowModel = workflowRepository.create(workflowModel); - Assert.assertTrue(!workflowModel.getTemplateId().isEmpty()); - - - - - /* - * Workflow Repository Update Operation Test - */ - workflowModel.setGraph("test"); - workflowRepository.update(workflowModel); - workflowModel = workflowRepository.get(templateId); - Assert.assertEquals(workflowModel.getGraph(), "test"); - - /* - * Workflow Repository Select Operation Test - */ - workflowModel = null; - workflowModel = workflowRepository.get(templateId); - Assert.assertNotNull(workflowModel); - - /* - * Workflow Repository Delete Operation - */ - - boolean deleteResult = workflowRepository.delete(templateId); - Assert.assertTrue(deleteResult); - - deleteResult = userProfileRepository.delete(userId); - Assert.assertTrue(deleteResult); - - deleteResult = gatewayRepository.delete(gatewayId); - Assert.assertTrue(deleteResult); - - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/1d96b11e/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/WorkflowRepositoryTest.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/WorkflowRepositoryTest.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/WorkflowRepositoryTest.java new file mode 100644 index 0000000..b17432c --- /dev/null +++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/WorkflowRepositoryTest.java @@ -0,0 +1,132 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.registry.core.repositories; + +import org.apache.airavata.model.WorkflowModel; +import org.apache.airavata.model.user.UserProfile; +import org.apache.airavata.model.workspace.Gateway; +import org.apache.airavata.model.workspace.GatewayApprovalStatus; +import org.apache.airavata.registry.core.entities.workflowcatalog.WorkflowEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity; +import org.apache.airavata.registry.core.repositories.workflowcatalog.WorkflowRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.GatewayRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.UserProfileRepository; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class WorkflowRepositoryTest { + private final static Logger logger = LoggerFactory.getLogger(WorkflowRepositoryTest.class); + + private GatewayRepository gatewayRepository; + private UserProfileRepository userProfileRepository; + private WorkflowRepository workflowRepository; + private String gatewayId; + private String userId; + private String templateId; + + private final String GATEWAY_DOMAIN = "test1.com"; + private final String WORKFLOW_NAME = "test Workflow"; + + @Before + public void setupRepository() { + gatewayRepository = new GatewayRepository(Gateway.class, GatewayEntity.class); + userProfileRepository = new UserProfileRepository(UserProfile.class, UserProfileEntity.class); + gatewayId = "test.com" + System.currentTimeMillis(); + userId = "testuser" + System.currentTimeMillis(); + workflowRepository = new WorkflowRepository(WorkflowModel.class, WorkflowEntity.class); + templateId = "templateId" + System.currentTimeMillis(); + } + + + @Test + public void workflowRepositoryTest() { + + /* + * Creating Gateway required for UserProfile & Workflow 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 Workflow Creation + */ + UserProfile userProfile = new UserProfile(); + userProfile.setAiravataInternalUserId(userId); + userProfile.setGatewayId(gateway.getGatewayId()); + userProfile = userProfileRepository.create(userProfile); + Assert.assertTrue(!userProfile.getAiravataInternalUserId().isEmpty()); + + /* + * Workflow Instance Creation + */ + + WorkflowModel workflowModel = new WorkflowModel(); + workflowModel.setTemplateId(templateId); + workflowModel.setCreatedUser(userId); + workflowModel.setGatewayId(gatewayId); + workflowModel.setName(WORKFLOW_NAME); + + + /* + * Workflow Repository Insert Operation Test + */ + workflowModel = workflowRepository.create(workflowModel); + Assert.assertTrue(!workflowModel.getTemplateId().isEmpty()); + + + /* + * Workflow Repository Update Operation Test + */ + workflowModel.setGraph("test"); + workflowRepository.update(workflowModel); + workflowModel = workflowRepository.get(templateId); + Assert.assertEquals(workflowModel.getGraph(), "test"); + + /* + * Workflow Repository Select Operation Test + */ + workflowModel = workflowRepository.get(templateId); + Assert.assertNotNull(workflowModel); + + /* + * Workflow Repository Delete Operation + */ + + boolean deleteResult = workflowRepository.delete(templateId); + Assert.assertTrue(deleteResult); + + deleteResult = userProfileRepository.delete(userId); + Assert.assertTrue(deleteResult); + + deleteResult = gatewayRepository.delete(gatewayId); + Assert.assertTrue(deleteResult); + + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/1d96b11e/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/WorkspaceRepositoryTest.java ---------------------------------------------------------------------- diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/WorkspaceRepositoryTest.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/WorkspaceRepositoryTest.java new file mode 100644 index 0000000..21a5a6e --- /dev/null +++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/WorkspaceRepositoryTest.java @@ -0,0 +1,279 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ +package org.apache.airavata.registry.core.repositories; + +import org.apache.airavata.model.user.UserProfile; +import org.apache.airavata.model.workspace.Gateway; +import org.apache.airavata.model.workspace.GatewayApprovalStatus; +import org.apache.airavata.model.workspace.Notification; +import org.apache.airavata.model.workspace.Project; +import org.apache.airavata.registry.core.entities.workspacecatalog.GatewayEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.NotificationEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.ProjectEntity; +import org.apache.airavata.registry.core.entities.workspacecatalog.UserProfileEntity; +import org.apache.airavata.registry.core.repositories.workspacecatalog.GatewayRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.NotificationRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.ProjectRepository; +import org.apache.airavata.registry.core.repositories.workspacecatalog.UserProfileRepository; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.UUID; + +public class WorkspaceRepositoryTest { + private final static Logger logger = LoggerFactory.getLogger(WorkspaceRepositoryTest.class); + + private GatewayRepository gatewayRepository; + private NotificationRepository notificationRepository; + private UserProfileRepository userProfileRepository; + private ProjectRepository projectRepository; + private String gatewayId; + private String notificationId; + private String userId; + private String projectId; + + 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"; + + + @Before + public void setupRepository() { + + gatewayRepository = new GatewayRepository(Gateway.class, GatewayEntity.class); + notificationRepository = new NotificationRepository(Notification.class, + NotificationEntity.class); + userProfileRepository = new UserProfileRepository(UserProfile.class, UserProfileEntity.class); + projectRepository = new ProjectRepository(Project.class, ProjectEntity.class); + + gatewayId = "test.com" + System.currentTimeMillis(); + notificationId = UUID.randomUUID().toString(); + userId = "testuser" + System.currentTimeMillis(); + projectId = "project" + System.currentTimeMillis(); + } + + + @Test + public void gateWayRepositoryTest() { + Gateway gateway = new Gateway(); + gateway.setGatewayApprovalStatus(GatewayApprovalStatus.ACTIVE); + gateway.setGatewayId(gatewayId); + + /* + * GateWay Repository Insert Operation Test + */ + gateway = gatewayRepository.create(gateway); + Assert.assertTrue(!gateway.getGatewayId().isEmpty()); + + /* + * GateWay Repository Update Operation Test + */ + gateway.setDomain(GATEWAY_DOMAIN); + gatewayRepository.update(gateway); + gateway = gatewayRepository.get(gateway.getGatewayId()); + Assert.assertEquals(gateway.getDomain(), GATEWAY_DOMAIN); + + /* + * GateWay Repository Select Operation Test + */ + gateway = null; + gateway = gatewayRepository.get(gatewayId); + Assert.assertNotNull(gateway); + + /* + * GateWay Repository Delete Operation + */ + boolean deleteResult = gatewayRepository.delete(gatewayId); + Assert.assertTrue(deleteResult); + + } + + @Test + public void notificationRepositoryTest() { + + String tempNotificationId = null; + Gateway gateway = new Gateway(); + gateway.setGatewayApprovalStatus(GatewayApprovalStatus.ACTIVE); + gateway.setGatewayId(gatewayId); + gateway.setDomain(GATEWAY_DOMAIN); + gateway = gatewayRepository.create(gateway); + + Notification notification = new Notification(); + notification.setGatewayId(gateway.getGatewayId()); + notification.setNotificationId(notificationId); + + /* + * Notification INSERT Operation Test + */ + notification = notificationRepository.create(notification); + Assert.assertTrue(!notification.getNotificationId().isEmpty()); + + /* + * Notification SELECT Operation Test + */ + tempNotificationId = notification.getNotificationId(); + notification = null; + notification = notificationRepository.get(tempNotificationId); + Assert.assertNotNull(notification); + + + /* + * Notification UPDATE Operation Test + */ + notification.setNotificationMessage(NOTIFY_MESSAGE); + notificationRepository.update(notification); + notification = notificationRepository.get(notification.getNotificationId()); + Assert.assertEquals(NOTIFY_MESSAGE, notification.getNotificationMessage()); + + /* + * Notification DELETE Operation Test + */ + boolean result = notificationRepository.delete(tempNotificationId); + Assert.assertTrue(result); + + gatewayRepository.delete(gatewayId); + } + + @Test + public void userProfileRepositoryTest() { + + /* + * Creating Gateway required for UserProfile 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 + */ + UserProfile userProfile = new UserProfile(); + userProfile.setAiravataInternalUserId(userId); + userProfile.setGatewayId(gateway.getGatewayId()); + + /* + * Workspace UserProfile Repository Insert Operation Test + */ + userProfile = userProfileRepository.create(userProfile); + Assert.assertTrue(!userProfile.getAiravataInternalUserId().isEmpty()); + + /* + * Workspace UserProfile Repository Update Operation Test + */ + userProfile.setComments(USER_COMMENT); + userProfileRepository.update(userProfile); + userProfile = userProfileRepository.get(userId); + System.out.println(userProfile.getComments()); + Assert.assertEquals(userProfile.getComments(), USER_COMMENT); + + /* + * Workspace UserProfile Repository Select Operation Test + */ + userProfile = userProfileRepository.get(userId); + Assert.assertNotNull(userProfile); + + /* + * Workspace UserProfile Repository Delete Operation + */ + boolean deleteResult = userProfileRepository.delete(userId); + Assert.assertTrue(deleteResult); + deleteResult = gatewayRepository.delete(gatewayId); + Assert.assertTrue(deleteResult); + + + } + + @Test + public void projectRepositoryTest() { + + /* + * 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); + + + /* + * Workspace Project Repository Insert Operation Test + */ + project = projectRepository.create(project); + Assert.assertTrue(!project.getProjectID().isEmpty()); + + /* + * Workspace Project Repository Update Operation Test + */ + project.setDescription(PROJECT_DESCRIPTION); + projectRepository.update(project); + project = projectRepository.get(projectId); + Assert.assertEquals(project.getDescription(), PROJECT_DESCRIPTION); + + /* + * Workspace Project Repository Select Operation Test + */ + project = projectRepository.get(projectId); + Assert.assertNotNull(project); + + /* + * Workspace Project Repository Delete Operation + */ + boolean 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
