Making changes to Gateway and Notification tests
MODIFY
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProjectRepository.java
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProjectRepository.java
@@ -122,14 +122,12 @@ public class ProjectRepository extends ExpCatAbstractRepository<Project, Project
public List<Project> searchAllAccessibleProjects(List<String> accessibleProjectIds, Map<String, String> filters, int limit,
int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException {
- String query = "SELECT DISTINCT P FROM " + ProjectEntity.class.getSimpleName() + " P ";
+ String query = "SELECT DISTINCT P FROM " + ProjectEntity.class.getSimpleName() + " P WHERE ";
if (!filters.isEmpty() && filters != null) {
for (String field : filters.keySet()) {
- query += " WHERE ";
-
if (field.equals(DBConstants.Project.GATEWAY_ID)) {
logger.debug("Filter Projects by Gateway ID");
query += "P.gatewayId LIKE :" + filters.get(field) + " AND ";
@@ -159,9 +157,13 @@ public class ProjectRepository extends ExpCatAbstractRepository<Project, Project
}
- if (!accessibleProjectIds.isEmpty() && accessibleProjectIds != null) {
+ if (accessibleProjectIds != null && !accessibleProjectIds.isEmpty()) {
logger.debug("Filter Projects by Accessible Project IDs");
- query += " P.projectId IN :" + accessibleProjectIds;
+ query += "P.projectId IN (";
+ for(String projectId : accessibleProjectIds) {
+ query += (":" + projectId + ",");
+ }
+ query = query.substring(0, query.length() - 1) + ")";
}
else {

MODIFY
modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/GatewayRepositoryTest.java
modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/GatewayRepositoryTest.java
package org.apache.airavata.registry.core.repositories.expcatalog;
+import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.registry.core.repositories.expcatalog.util.Initialize;
-import org.apache.airavata.registry.core.utils.DBConstants;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.registry.cpi.RegistryException;
import org.junit.After;
import org.junit.Before;
@@ -16,6 +17,7 @@ import static org.junit.Assert.assertFalse;
public class GatewayRepositoryTest {
private static Initialize initialize;
+ private String testGatewayId = "testGateway";
GatewayRepository gatewayRepository;
private static final Logger logger = LoggerFactory.getLogger(GatewayRepositoryTest.class);
@@ -37,8 +39,25 @@ public class GatewayRepositoryTest {
}
@Test
- public void GatewayRepositoryTest() throws RegistryException {
+ public void GatewayRepositoryTest() throws ApplicationSettingsException, RegistryException {
+ Gateway gateway = new Gateway();
+ gateway.setGatewayId(testGatewayId);
+ gateway.setDomain("SEAGRID");
+ gateway.setEmailAddress("abc@d.com");
+ String gatewayId = gatewayRepository.addGateway(gateway);
+ assertEquals(testGatewayId, gatewayId);
+
+ gateway.setGatewayAdminFirstName("ABC");
+ gatewayRepository.updateGateway(testGatewayId, gateway);
+
+ Gateway retrievedGateway = gatewayRepository.getGateway(gatewayId);
+ assertEquals(gateway.getGatewayAdminFirstName(), retrievedGateway.getGatewayAdminFirstName());
+
+ assertTrue(gatewayRepository.getAllGateways().size() == 1);
+
+ gatewayRepository.removeGateway(gatewayId);
+ assertFalse(gatewayRepository.isGatewayExist(gatewayId));
}
}

MODIFY
modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/NotificationRepositoryTest.java
modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/NotificationRepositoryTest.java
package org.apache.airavata.registry.core.repositories.expcatalog;
+import org.apache.airavata.model.workspace.Notification;
+import org.apache.airavata.model.workspace.NotificationPriority;
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.junit.After;
import org.junit.Before;
@@ -11,11 +12,11 @@ import org.slf4j.LoggerFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
public class NotificationRepositoryTest {
private static Initialize initialize;
+ private String testGateway = "testGateway";
NotificationRepository notificationRepository;
private static final Logger logger = LoggerFactory.getLogger(NotificationRepositoryTest.class);
@@ -38,7 +39,24 @@ public class NotificationRepositoryTest {
@Test
public void NotificationRepositoryTest() throws RegistryException {
+ Notification notification = new Notification();
+ notification.setNotificationId("notificationId");
+ notification.setGatewayId(testGateway);
+ notification.setTitle("notificationTitle");
+ notification.setNotificationMessage("notificationMessage");
+ String notificationId = notificationRepository.createNotification(notification);
+ assertEquals(notification.getNotificationId(), notificationId);
+
+ notification.setPriority(NotificationPriority.NORMAL);
+ notificationRepository.updateNotification(notification);
+
+ Notification retrievedNotification = notificationRepository.getNotification(notificationId);
+ assertEquals(NotificationPriority.NORMAL, retrievedNotification.getPriority());
+
+ assertTrue(notificationRepository.getAllGatewayNotifications(testGateway).size() == 1);
+
+ notificationRepository.deleteNotification(notificationId);
}
}

Making changes to Gateway and Notification tests