This is an automated email from the ASF dual-hosted git repository. yasith pushed a commit to branch service-layer-improvements in repository https://gitbox.apache.org/repos/asf/airavata.git
commit 9549fe89d4af37602cbc4da5db1f42da20fc147d Author: yasithdev <[email protected]> AuthorDate: Wed Dec 10 16:30:22 2025 -0600 fix DI issues, update test cases --- .../airavata/config/AiravataServerProperties.java | 9 ---- .../helix/core/participant/HelixParticipant.java | 54 ++++++++++++++++++---- .../helix/impl/participant/GlobalParticipant.java | 26 +++++++++-- .../helix/impl/workflow/PreWorkflowManager.java | 2 + .../airavata/messaging/core/MessagingFactory.java | 5 ++ .../orchestrator/impl/SimpleOrchestratorImpl.java | 2 + .../apache/airavata/profile/utils/JPAUtils.java | 3 ++ .../apache/airavata/service/AiravataService.java | 6 ++- .../airavata/service/CredentialStoreService.java | 1 + .../airavata/service/OrchestratorService.java | 4 ++ .../apache/airavata/sharing/utils/JPAUtils.java | 3 ++ .../repositories/WorkspaceRepositoryTest.java | 38 ++++++++++++++- .../ApplicationDeploymentRepositoryTest.java | 42 ++++++++++++++++- .../ApplicationInterfaceRepositoryTest.java | 42 ++++++++++++++++- .../appcatalog/ComputeResourceRepositoryTest.java | 44 +++++++++++++++++- .../appcatalog/GatewayGroupsRepositoryTest.java | 42 ++++++++++++++++- .../appcatalog/GatewayProfileRepositoryTest.java | 42 ++++++++++++++++- .../GroupResourceProfileRepositoryTest.java | 45 ++++++++++++++++-- .../JobSubmissionInterfaceRepositoryTest.java | 40 +++++++++++++++- .../appcatalog/StorageResourceRepositoryTest.java | 44 +++++++++++++++++- .../UserResourceProfileRepositoryTest.java | 44 +++++++++++++++++- .../expcatalog/ExperimentErrorRepositoryTest.java | 40 +++++++++++++++- .../expcatalog/ExperimentInputRepositoryTest.java | 42 ++++++++++++++++- .../expcatalog/ExperimentOutputRepositoryTest.java | 42 ++++++++++++++++- .../expcatalog/ExperimentRepositoryTest.java | 2 + .../expcatalog/ExperimentStatusRepositoryTest.java | 40 +++++++++++++++- .../ExperimentSummaryRepositoryTest.java | 42 ++++++++++++++++- .../expcatalog/GatewayRepositoryTest.java | 2 + .../repositories/expcatalog/JobRepositoryTest.java | 2 + .../expcatalog/JobStatusRepositoryTest.java | 2 + .../expcatalog/NotificationRepositoryTest.java | 40 +++++++++++++++- .../expcatalog/ProcessErrorRepositoryTest.java | 42 ++++++++++++++++- .../expcatalog/ProcessInputRepositoryTest.java | 42 ++++++++++++++++- .../expcatalog/ProcessOutputRepositoryTest.java | 42 ++++++++++++++++- .../expcatalog/ProcessRepositoryTest.java | 2 + .../expcatalog/ProcessStatusRepositoryTest.java | 2 + .../expcatalog/ProjectRepositoryTest.java | 9 +++- .../expcatalog/QueueStatusRepositoryTest.java | 2 + .../expcatalog/TaskErrorRepositoryTest.java | 42 ++++++++++++++++- .../expcatalog/TaskRepositoryTest.java | 2 + .../expcatalog/TaskStatusRepositoryTest.java | 2 + .../expcatalog/UserRepositoryTest.java | 2 + .../replicacatalog/DataProductRepositoryTest.java | 42 ++++++++++++++++- .../DataReplicaLocationRepositoryTest.java | 42 ++++++++++++++++- .../workflowcatalog/WorkflowRepositoryTest.java | 40 +++++++++++++++- 45 files changed, 1040 insertions(+), 65 deletions(-) diff --git a/airavata-api/src/main/java/org/apache/airavata/config/AiravataServerProperties.java b/airavata-api/src/main/java/org/apache/airavata/config/AiravataServerProperties.java index 94bcc3cc10..bbf28f14fb 100644 --- a/airavata-api/src/main/java/org/apache/airavata/config/AiravataServerProperties.java +++ b/airavata-api/src/main/java/org/apache/airavata/config/AiravataServerProperties.java @@ -39,12 +39,9 @@ public class AiravataServerProperties { public AiravataServerProperties() { // No-arg constructor required for @ConfigurationProperties - logger.info("[BEAN-INIT] AiravataServerProperties constructor called"); } public void setEnvironment(Environment environment) { - logger.info("[BEAN-INIT] setEnvironment() called on AiravataServerProperties - environment is {}", - environment != null ? "SET" : "NULL"); this.environment = environment; } @@ -53,8 +50,6 @@ public class AiravataServerProperties { @PostConstruct public void bindProperties() { - logger.info("[BEAN-INIT] bindProperties() called on AiravataServerProperties - environment is {}", - environment != null ? "SET" : "NULL"); logger.info("Binding properties to AiravataServerProperties"); // Manually bind database properties from environment @@ -148,10 +143,6 @@ public class AiravataServerProperties { } private String getProperty(String key, String defaultValue) { - if (environment == null) { - logger.warn("[BEAN-INIT] Environment is null when calling getProperty({}), returning default", key); - return defaultValue; - } String value = environment.getProperty(key); return value != null ? value : defaultValue; } diff --git a/airavata-api/src/main/java/org/apache/airavata/helix/core/participant/HelixParticipant.java b/airavata-api/src/main/java/org/apache/airavata/helix/core/participant/HelixParticipant.java index e8fbf79b51..a202ae00a1 100644 --- a/airavata-api/src/main/java/org/apache/airavata/helix/core/participant/HelixParticipant.java +++ b/airavata-api/src/main/java/org/apache/airavata/helix/core/participant/HelixParticipant.java @@ -67,17 +67,29 @@ public class HelixParticipant<T extends AbstractTask> implements Runnable { logger.info("Initializing Participant Node"); this.properties = properties; - this.zkAddress = properties.zookeeper.serverConnection; - this.clusterName = properties.helix.clusterName; - this.participantName = getParticipantName(); - this.taskTypeName = taskTypeName; - this.taskClasses = taskClasses; + this.taskClasses = taskClasses; // Can be null for deferred initialization + + // Property-dependent initialization moved to initialize() method + // This allows subclasses to set taskClasses before initializing properties + } - logger.info("Zookeeper connection URL " + zkAddress); - logger.info("Cluster name " + clusterName); - logger.info("Participant name " + participantName); - logger.info("Task type " + taskTypeName); + /** + * Initialize property-dependent fields. This method should be called after + * taskClasses are set (if deferred initialization is used). + * Can be called from @PostConstruct in subclasses. + */ + protected void initialize() { + if (properties != null) { + this.zkAddress = properties.zookeeper.serverConnection; + this.clusterName = properties.helix.clusterName; + this.participantName = getParticipantName(); + + logger.info("Zookeeper connection URL " + zkAddress); + logger.info("Cluster name " + clusterName); + logger.info("Participant name " + participantName); + logger.info("Task type " + taskTypeName); + } if (taskClasses != null) { for (Class<? extends T> taskClass : taskClasses) { @@ -86,6 +98,26 @@ public class HelixParticipant<T extends AbstractTask> implements Runnable { } } + /** + * Set task classes after construction. Used for deferred initialization. + * + * @param taskClasses the task classes to set + * @throws IllegalStateException if task classes are already set and not empty + */ + public void setTaskClasses(List<Class<? extends T>> taskClasses) { + if (this.taskClasses != null && !this.taskClasses.isEmpty()) { + throw new IllegalStateException("Task classes already set"); + } + this.taskClasses = taskClasses; + + // Log task classes if they were set + if (taskClasses != null && !taskClasses.isEmpty()) { + for (Class<? extends T> taskClass : taskClasses) { + logger.info("Task classes include: " + taskClass.getCanonicalName()); + } + } + } + public HelixParticipant(Class<T> taskClass, String taskTypeName, AiravataServerProperties properties) { this(taskClass != null ? Collections.singletonList(taskClass) : null, taskTypeName, properties); } @@ -110,6 +142,10 @@ public class HelixParticipant<T extends AbstractTask> implements Runnable { @SuppressWarnings("WeakerAccess") public Map<String, TaskFactory> getTaskFactory() { + if (taskClasses == null || taskClasses.isEmpty()) { + throw new IllegalStateException("Task classes must be set before creating task factory"); + } + Map<String, TaskFactory> taskRegistry = new HashMap<>(); for (Class<? extends T> taskClass : taskClasses) { diff --git a/airavata-api/src/main/java/org/apache/airavata/helix/impl/participant/GlobalParticipant.java b/airavata-api/src/main/java/org/apache/airavata/helix/impl/participant/GlobalParticipant.java index 06aeb24cc2..71d9c3d35f 100644 --- a/airavata-api/src/main/java/org/apache/airavata/helix/impl/participant/GlobalParticipant.java +++ b/airavata-api/src/main/java/org/apache/airavata/helix/impl/participant/GlobalParticipant.java @@ -21,15 +21,17 @@ package org.apache.airavata.helix.impl.participant; import java.util.ArrayList; import java.util.List; -import org.apache.airavata.common.exception.ApplicationSettingsException; +import jakarta.annotation.PostConstruct; import org.apache.airavata.config.AiravataServerProperties; import org.apache.airavata.helix.core.AbstractTask; import org.apache.airavata.helix.core.participant.HelixParticipant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Component; @Component +@DependsOn("airavataServerProperties") public class GlobalParticipant extends HelixParticipant<AbstractTask> { private static final Logger logger = LoggerFactory.getLogger(GlobalParticipant.class); @@ -58,14 +60,28 @@ public class GlobalParticipant extends HelixParticipant<AbstractTask> { @SuppressWarnings("WeakerAccess") public GlobalParticipant( - List<Class<? extends AbstractTask>> taskClasses, String taskTypeName, AiravataServerProperties properties) - throws ApplicationSettingsException { + List<Class<? extends AbstractTask>> taskClasses, String taskTypeName, AiravataServerProperties properties) { super(taskClasses, taskTypeName, properties); + // Initialize property-dependent fields immediately for programmatic creation + initialize(); } // Constructor for Spring - uses constructor injection for properties - public GlobalParticipant(AiravataServerProperties properties) throws ApplicationSettingsException { - super(createTaskClasses(), null, properties); + // No checked exceptions - initialization happens in @PostConstruct + public GlobalParticipant(AiravataServerProperties properties) { + // Pass empty list for taskClasses - will be set in @PostConstruct + // Using Collections.emptyList() to avoid ambiguity with Class<T> constructor + super(new ArrayList<>(), null, properties); + } + + @PostConstruct + public void init() { + // All initialization logic here - no exceptions in constructor + List<Class<? extends AbstractTask>> taskClasses = createTaskClasses(); + setTaskClasses(taskClasses); + + // Initialize parent's property-dependent fields + initialize(); } private static List<Class<? extends AbstractTask>> createTaskClasses() { diff --git a/airavata-api/src/main/java/org/apache/airavata/helix/impl/workflow/PreWorkflowManager.java b/airavata-api/src/main/java/org/apache/airavata/helix/impl/workflow/PreWorkflowManager.java index b9e702af98..3087fd64ee 100644 --- a/airavata-api/src/main/java/org/apache/airavata/helix/impl/workflow/PreWorkflowManager.java +++ b/airavata-api/src/main/java/org/apache/airavata/helix/impl/workflow/PreWorkflowManager.java @@ -58,9 +58,11 @@ import org.apache.airavata.registry.api.exception.RegistryServiceException; import org.apache.airavata.service.RegistryService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Component; @Component +@DependsOn("messagingFactory") public class PreWorkflowManager extends WorkflowManager { private static final Logger logger = LoggerFactory.getLogger(PreWorkflowManager.class); diff --git a/airavata-api/src/main/java/org/apache/airavata/messaging/core/MessagingFactory.java b/airavata-api/src/main/java/org/apache/airavata/messaging/core/MessagingFactory.java index 7b5ad14d77..926a595ac9 100644 --- a/airavata-api/src/main/java/org/apache/airavata/messaging/core/MessagingFactory.java +++ b/airavata-api/src/main/java/org/apache/airavata/messaging/core/MessagingFactory.java @@ -33,11 +33,14 @@ import org.apache.airavata.model.messaging.event.ProcessIdentifier; import org.apache.airavata.model.messaging.event.ProcessStatusChangeEvent; import org.apache.airavata.model.messaging.event.TaskOutputChangeEvent; import org.apache.airavata.model.messaging.event.TaskStatusChangeEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @Component public class MessagingFactory { + private static final Logger logger = LoggerFactory.getLogger(MessagingFactory.class); private static MessagingFactory instance; private final AiravataServerProperties properties; @@ -48,7 +51,9 @@ public class MessagingFactory { @jakarta.annotation.PostConstruct public void init() { + logger.info("[BEAN-INIT] MessagingFactory.init() called - setting static instance"); instance = this; + logger.info("[BEAN-INIT] MessagingFactory static instance set successfully"); } public static Subscriber getSubscriber(final MessageHandler messageHandler, List<String> routingKeys, Type type) diff --git a/airavata-api/src/main/java/org/apache/airavata/orchestrator/impl/SimpleOrchestratorImpl.java b/airavata-api/src/main/java/org/apache/airavata/orchestrator/impl/SimpleOrchestratorImpl.java index 95c4d249be..ae35f576a2 100644 --- a/airavata-api/src/main/java/org/apache/airavata/orchestrator/impl/SimpleOrchestratorImpl.java +++ b/airavata-api/src/main/java/org/apache/airavata/orchestrator/impl/SimpleOrchestratorImpl.java @@ -118,7 +118,9 @@ public class SimpleOrchestratorImpl extends AbstractOrchestrator { @jakarta.annotation.PostConstruct public void init() throws OrchestratorException { + logger.info("[BEAN-INIT] SimpleOrchestratorImpl.init() called"); initialize(properties); + logger.info("[BEAN-INIT] SimpleOrchestratorImpl initialized successfully"); } public boolean launchProcess(ProcessModel processModel, String tokenId) throws OrchestratorException { diff --git a/airavata-api/src/main/java/org/apache/airavata/profile/utils/JPAUtils.java b/airavata-api/src/main/java/org/apache/airavata/profile/utils/JPAUtils.java index b1ea093cff..d629575f51 100644 --- a/airavata-api/src/main/java/org/apache/airavata/profile/utils/JPAUtils.java +++ b/airavata-api/src/main/java/org/apache/airavata/profile/utils/JPAUtils.java @@ -40,10 +40,13 @@ public class JPAUtils { @PostConstruct public void init() { + org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(JPAUtils.class); + logger.info("[BEAN-INIT] ProfileService JPAUtils.init() called - setting static instance"); instance = this; var db = properties.database.profile; factory = org.apache.airavata.common.utils.JPAUtils.getEntityManagerFactory( PERSISTENCE_UNIT_NAME, db.driver, db.url, db.user, db.password, db.validationQuery); + logger.info("[BEAN-INIT] ProfileService JPAUtils static instance set successfully"); } public static EntityManager getEntityManager() { diff --git a/airavata-api/src/main/java/org/apache/airavata/service/AiravataService.java b/airavata-api/src/main/java/org/apache/airavata/service/AiravataService.java index bde814372c..ff3d8bb3da 100644 --- a/airavata-api/src/main/java/org/apache/airavata/service/AiravataService.java +++ b/airavata-api/src/main/java/org/apache/airavata/service/AiravataService.java @@ -228,9 +228,10 @@ public class AiravataService { @jakarta.annotation.PostConstruct public void initializePublishers() throws AiravataException { + logger.info("[BEAN-INIT] AiravataService.initializePublishers() called"); try { statusPublisher = MessagingFactory.getPublisher(Type.STATUS); - logger.info("Initialized StatusPublisher"); + logger.info("[BEAN-INIT] Initialized StatusPublisher"); } catch (AiravataException e) { String msg = String.format( "Error while getting StatusPublisher: %s. Publisher will be unavailable.", e.getMessage()); @@ -240,7 +241,7 @@ public class AiravataService { try { experimentPublisher = MessagingFactory.getPublisher(Type.EXPERIMENT_LAUNCH); - logger.info("Initialized ExperimentPublisher"); + logger.info("[BEAN-INIT] Initialized ExperimentPublisher"); } catch (AiravataException e) { String msg = String.format( "Error while getting ExperimentPublisher: %s. Publisher will be unavailable.", e.getMessage()); @@ -251,6 +252,7 @@ public class AiravataService { @jakarta.annotation.PostConstruct public void init() throws AiravataException { + logger.info("[BEAN-INIT] AiravataService.init() called"); try { initSharingRegistry(); } catch (SharingRegistryException | DuplicateEntryException e) { diff --git a/airavata-api/src/main/java/org/apache/airavata/service/CredentialStoreService.java b/airavata-api/src/main/java/org/apache/airavata/service/CredentialStoreService.java index 37331405d2..0974cdc5fe 100644 --- a/airavata-api/src/main/java/org/apache/airavata/service/CredentialStoreService.java +++ b/airavata-api/src/main/java/org/apache/airavata/service/CredentialStoreService.java @@ -76,6 +76,7 @@ public class CredentialStoreService { @jakarta.annotation.PostConstruct public void init() { + logger.info("[BEAN-INIT] CredentialStoreService.init() called"); var db = properties.database.vault; String jdbcUrl = db.url; if (jdbcUrl == null || jdbcUrl.isEmpty()) { diff --git a/airavata-api/src/main/java/org/apache/airavata/service/OrchestratorService.java b/airavata-api/src/main/java/org/apache/airavata/service/OrchestratorService.java index a2bb38a57f..065406815d 100644 --- a/airavata-api/src/main/java/org/apache/airavata/service/OrchestratorService.java +++ b/airavata-api/src/main/java/org/apache/airavata/service/OrchestratorService.java @@ -82,9 +82,11 @@ import org.apache.zookeeper.data.Stat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; +import org.springframework.context.annotation.DependsOn; import org.springframework.stereotype.Service; @Service +@DependsOn("messagingFactory") public class OrchestratorService { private static final Logger logger = LoggerFactory.getLogger(OrchestratorService.class); @@ -113,8 +115,10 @@ public class OrchestratorService { @PostConstruct public void postConstruct() { + logger.info("[BEAN-INIT] OrchestratorService.postConstruct() called"); try { initializeInternal(); + logger.info("[BEAN-INIT] OrchestratorService initialized successfully"); } catch (OrchestratorException e) { logger.error("Failed to initialize OrchestratorService", e); throw new RuntimeException("Failed to initialize OrchestratorService", e); diff --git a/airavata-api/src/main/java/org/apache/airavata/sharing/utils/JPAUtils.java b/airavata-api/src/main/java/org/apache/airavata/sharing/utils/JPAUtils.java index 6a2d2e10bb..569d31af4d 100644 --- a/airavata-api/src/main/java/org/apache/airavata/sharing/utils/JPAUtils.java +++ b/airavata-api/src/main/java/org/apache/airavata/sharing/utils/JPAUtils.java @@ -40,7 +40,10 @@ public class JPAUtils { @PostConstruct public void init() { + org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(JPAUtils.class); + logger.info("[BEAN-INIT] SharingRegistry JPAUtils.init() called - setting static instance"); instance = this; + logger.info("[BEAN-INIT] SharingRegistry JPAUtils static instance set successfully"); } public static EntityManager getEntityManager() { diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/WorkspaceRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/WorkspaceRepositoryTest.java index a49ed8b772..a0aa72b22c 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/WorkspaceRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/WorkspaceRepositoryTest.java @@ -20,15 +20,51 @@ package org.apache.airavata.registry.repositories; import org.apache.airavata.registry.repositories.common.TestBase; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; import org.springframework.transaction.annotation.Transactional; -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, WorkspaceRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") @Transactional public class WorkspaceRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + // private final static Logger logger = LoggerFactory.getLogger(WorkspaceRepositoryTest.class); // // private GatewayRepository gatewayRepository; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationDeploymentRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationDeploymentRepositoryTest.java index 678d80ec4b..30543a3801 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationDeploymentRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationDeploymentRepositoryTest.java @@ -38,13 +38,51 @@ import org.apache.airavata.registry.utils.DBConstants; import org.apache.commons.lang3.builder.EqualsBuilder; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; - -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, ApplicationDeploymentRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ApplicationDeploymentRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final ComputeResourceService computeResourceService; private final ApplicationInterfaceService applicationInterfaceService; private final ApplicationDeploymentService applicationDeploymentService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java index 5d07ef8975..434816fe22 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java @@ -40,13 +40,51 @@ import org.apache.airavata.registry.utils.DBConstants; import org.apache.commons.lang3.builder.EqualsBuilder; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; - -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, ApplicationInterfaceRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ApplicationInterfaceRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final ApplicationInterfaceService applicationInterfaceService; private final ComputeResourceService computeResourceService; private final ApplicationDeploymentService applicationDeploymentService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ComputeResourceRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ComputeResourceRepositoryTest.java index cdaec1febf..4137d960ab 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ComputeResourceRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/ComputeResourceRepositoryTest.java @@ -32,11 +32,53 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, ComputeResourceRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ComputeResourceRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final ComputeResourceService computeResourceService; public ComputeResourceRepositoryTest(ComputeResourceService computeResourceService) { diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayGroupsRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayGroupsRepositoryTest.java index 1c0176b97f..8f8f679b07 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayGroupsRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayGroupsRepositoryTest.java @@ -24,13 +24,51 @@ import org.apache.airavata.registry.repositories.common.TestBase; import org.apache.airavata.registry.services.GatewayGroupsService; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; - -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, GatewayGroupsRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class GatewayGroupsRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private static final String GATEWAY_ID = "gateway-id"; private static final String ADMIN_GROUPS_ID = "admin-groups-id"; private static final String READ_ONLY_ADMINS_GROUP_ID = "read-only-admins-group-id"; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayProfileRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayProfileRepositoryTest.java index 4d65efdb03..e65e19a1ca 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayProfileRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GatewayProfileRepositoryTest.java @@ -41,13 +41,51 @@ import org.apache.airavata.registry.services.GwyResourceProfileService; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; - -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, GatewayProfileRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class GatewayProfileRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private static final Logger logger = LoggerFactory.getLogger(GatewayProfileRepositoryTest.class); private final GwyResourceProfileService gwyResourceProfileService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GroupResourceProfileRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GroupResourceProfileRepositoryTest.java index d2762d9d0d..0146ef1446 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GroupResourceProfileRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/GroupResourceProfileRepositoryTest.java @@ -36,15 +36,54 @@ import org.apache.airavata.registry.services.ComputeResourceService; import org.apache.airavata.registry.services.GroupResourceProfileService; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.TestPropertySource; // FIXME - update the codes changed by GroupComputeResourcePreference -> abstract GroupComputeResourcePreference + // SlurmGroupComputeResourcePreference -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, GroupResourceProfileRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class GroupResourceProfileRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final ComputeResourceService computeResourceService; private final GroupResourceProfileService groupResourceProfileService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/JobSubmissionInterfaceRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/JobSubmissionInterfaceRepositoryTest.java index 07e6bc9e38..de4c5e64af 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/JobSubmissionInterfaceRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/JobSubmissionInterfaceRepositoryTest.java @@ -33,13 +33,51 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, JobSubmissionInterfaceRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class JobSubmissionInterfaceRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final ComputeResourceService computeResourceService; private final JobSubmissionInterfaceRepository jobSubmissionInterfaceRepository; private final Mapper mapper; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/StorageResourceRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/StorageResourceRepositoryTest.java index e23f2f2642..fb9a0167e2 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/StorageResourceRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/StorageResourceRepositoryTest.java @@ -39,14 +39,56 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; /** * Created by skariyat on 3/13/18. */ -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, StorageResourceRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class StorageResourceRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private static final Logger logger = LoggerFactory.getLogger(StorageResourceRepository.class); private final StorageResourceService storageResourceService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/UserResourceProfileRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/UserResourceProfileRepositoryTest.java index 1ae8a90b71..aa502a70d8 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/UserResourceProfileRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/appcatalog/UserResourceProfileRepositoryTest.java @@ -32,11 +32,53 @@ import org.apache.airavata.registry.services.UserResourceProfileService; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, UserResourceProfileRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class UserResourceProfileRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final UserResourceProfileService userResourceProfileService; private String userId = "testUser"; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentErrorRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentErrorRepositoryTest.java index 6fad3bdb74..c2db51ba23 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentErrorRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentErrorRepositoryTest.java @@ -35,13 +35,51 @@ import org.apache.airavata.registry.services.ExperimentService; import org.apache.airavata.registry.services.GatewayService; import org.apache.airavata.registry.services.ProjectService; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, ExperimentErrorRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ExperimentErrorRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final GatewayService gatewayService; private final ProjectService projectService; private final ExperimentService experimentService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentInputRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentInputRepositoryTest.java index 8b97745d01..feb64a8624 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentInputRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentInputRepositoryTest.java @@ -37,13 +37,51 @@ import org.apache.airavata.registry.services.ExperimentService; import org.apache.airavata.registry.services.GatewayService; import org.apache.airavata.registry.services.ProjectService; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; - -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, ExperimentInputRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ExperimentInputRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final GatewayService gatewayService; private final ProjectService projectService; private final ExperimentService experimentService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentOutputRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentOutputRepositoryTest.java index 9c31751d78..2c4158e7a2 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentOutputRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentOutputRepositoryTest.java @@ -37,13 +37,51 @@ import org.apache.airavata.registry.services.ExperimentService; import org.apache.airavata.registry.services.GatewayService; import org.apache.airavata.registry.services.ProjectService; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; - -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, ExperimentOutputRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ExperimentOutputRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final GatewayService gatewayService; private final ProjectService projectService; private final ExperimentService experimentService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentRepositoryTest.java index 88729687f0..c052e7dbce 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentRepositoryTest.java @@ -42,6 +42,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; +import org.springframework.test.context.TestConstructor; import org.springframework.test.context.TestPropertySource; @SpringBootTest( @@ -51,6 +52,7 @@ import org.springframework.test.context.TestPropertySource; "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ExperimentRepositoryTest extends TestBase { @Configuration diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentStatusRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentStatusRepositoryTest.java index 3d38dbfc2b..ff7e266d22 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentStatusRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentStatusRepositoryTest.java @@ -35,13 +35,51 @@ import org.apache.airavata.registry.services.ExperimentStatusService; import org.apache.airavata.registry.services.GatewayService; import org.apache.airavata.registry.services.ProjectService; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, ExperimentStatusRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ExperimentStatusRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final GatewayService gatewayService; private final ProjectService projectService; private final ExperimentService experimentService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentSummaryRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentSummaryRepositoryTest.java index f27e432300..2db3e96642 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentSummaryRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ExperimentSummaryRepositoryTest.java @@ -42,13 +42,51 @@ import org.apache.airavata.registry.services.GatewayService; import org.apache.airavata.registry.services.ProjectService; import org.apache.airavata.registry.utils.DBConstants; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; - -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, ExperimentSummaryRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ExperimentSummaryRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final GatewayService gatewayService; private final ProjectService projectService; private final ExperimentService experimentService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/GatewayRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/GatewayRepositoryTest.java index a309b5c500..ad5e15f5e1 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/GatewayRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/GatewayRepositoryTest.java @@ -36,6 +36,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; +import org.springframework.test.context.TestConstructor; import org.springframework.test.context.TestPropertySource; @SpringBootTest( @@ -45,6 +46,7 @@ import org.springframework.test.context.TestPropertySource; "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class GatewayRepositoryTest extends TestBase { @Configuration diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobRepositoryTest.java index e58657339b..9e410e7c11 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobRepositoryTest.java @@ -52,6 +52,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; @SpringBootTest( classes = {org.apache.airavata.config.JpaConfig.class, JobRepositoryTest.TestConfiguration.class}, @@ -60,6 +61,7 @@ import org.springframework.test.context.TestPropertySource; "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class JobRepositoryTest extends TestBase { @Configuration diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobStatusRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobStatusRepositoryTest.java index bd4aacadba..c5dfa0d9f9 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobStatusRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/JobStatusRepositoryTest.java @@ -45,6 +45,7 @@ import org.apache.airavata.registry.services.TaskService; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.ComponentScan; @@ -59,6 +60,7 @@ import org.springframework.context.annotation.Import; "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class JobStatusRepositoryTest extends TestBase { @Configuration diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/NotificationRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/NotificationRepositoryTest.java index 92462c96af..42f95566fa 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/NotificationRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/NotificationRepositoryTest.java @@ -28,13 +28,51 @@ import org.apache.airavata.registry.exceptions.RegistryException; import org.apache.airavata.registry.repositories.common.TestBase; import org.apache.airavata.registry.services.NotificationService; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, NotificationRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class NotificationRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private String testGateway = "testGateway"; private final NotificationService notificationService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessErrorRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessErrorRepositoryTest.java index 759a0ea0f0..d1c3902546 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessErrorRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessErrorRepositoryTest.java @@ -37,13 +37,51 @@ import org.apache.airavata.registry.services.ProcessErrorService; import org.apache.airavata.registry.services.ProcessService; import org.apache.airavata.registry.services.ProjectService; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; - -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, ProcessErrorRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ProcessErrorRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final GatewayService gatewayService; private final ProjectService projectService; private final ExperimentService experimentService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessInputRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessInputRepositoryTest.java index 485998cc4a..a44bc0bbce 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessInputRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessInputRepositoryTest.java @@ -39,13 +39,51 @@ import org.apache.airavata.registry.services.ProcessInputService; import org.apache.airavata.registry.services.ProcessService; import org.apache.airavata.registry.services.ProjectService; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; - -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, ProcessInputRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ProcessInputRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final GatewayService gatewayService; private final ProjectService projectService; private final ExperimentService experimentService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessOutputRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessOutputRepositoryTest.java index 9ce273ddf5..91caf77d85 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessOutputRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessOutputRepositoryTest.java @@ -39,13 +39,51 @@ import org.apache.airavata.registry.services.ProcessOutputService; import org.apache.airavata.registry.services.ProcessService; import org.apache.airavata.registry.services.ProjectService; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; - -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, ProcessOutputRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ProcessOutputRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final GatewayService gatewayService; private final ProjectService projectService; private final ExperimentService experimentService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessRepositoryTest.java index aeb23e7b57..94ecf32d37 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessRepositoryTest.java @@ -47,6 +47,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; @SpringBootTest( classes = {org.apache.airavata.config.JpaConfig.class, ProcessRepositoryTest.TestConfiguration.class}, @@ -55,6 +56,7 @@ import org.springframework.test.context.TestPropertySource; "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ProcessRepositoryTest extends TestBase { @Configuration diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessStatusRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessStatusRepositoryTest.java index b05ff139c3..125daaf29a 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessStatusRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProcessStatusRepositoryTest.java @@ -40,6 +40,7 @@ import org.apache.airavata.registry.services.ProjectService; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.ComponentScan; @@ -54,6 +55,7 @@ import org.springframework.context.annotation.Import; "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ProcessStatusRepositoryTest extends TestBase { @Configuration diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProjectRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProjectRepositoryTest.java index af981a02d6..d2e3e5b792 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProjectRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/ProjectRepositoryTest.java @@ -39,6 +39,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; +import org.springframework.test.context.TestConstructor; import org.springframework.test.context.TestPropertySource; @SpringBootTest( @@ -48,12 +49,12 @@ import org.springframework.test.context.TestPropertySource; "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class ProjectRepositoryTest extends TestBase { @Configuration @ComponentScan( - basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config" - }, + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, excludeFilters = { @ComponentScan.Filter( type = FilterType.ASSIGNABLE_TYPE, @@ -75,6 +76,10 @@ public class ProjectRepositoryTest extends TestBase { }) @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + @org.springframework.boot.autoconfigure.SpringBootApplication(exclude = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class + }) static class TestConfiguration {} private final GatewayService gatewayService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/QueueStatusRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/QueueStatusRepositoryTest.java index 9c02c8d8ba..a427e06faf 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/QueueStatusRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/QueueStatusRepositoryTest.java @@ -36,6 +36,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; @SpringBootTest( classes = {org.apache.airavata.config.JpaConfig.class, QueueStatusRepositoryTest.TestConfiguration.class}, @@ -44,6 +45,7 @@ import org.springframework.test.context.TestPropertySource; "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class QueueStatusRepositoryTest extends TestBase { @Configuration diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskErrorRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskErrorRepositoryTest.java index 278a1340ba..47d45ffaa3 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskErrorRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskErrorRepositoryTest.java @@ -40,13 +40,51 @@ import org.apache.airavata.registry.services.ProjectService; import org.apache.airavata.registry.services.TaskErrorService; import org.apache.airavata.registry.services.TaskService; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; - -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, TaskErrorRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class TaskErrorRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final GatewayService gatewayService; private final ProjectService projectService; private final ExperimentService experimentService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskRepositoryTest.java index 547a918ee2..f994894e5c 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskRepositoryTest.java @@ -49,6 +49,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; @SpringBootTest( classes = {org.apache.airavata.config.JpaConfig.class, TaskRepositoryTest.TestConfiguration.class}, @@ -57,6 +58,7 @@ import org.springframework.test.context.TestPropertySource; "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class TaskRepositoryTest extends TestBase { @Configuration diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskStatusRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskStatusRepositoryTest.java index 07d404a0fc..8a59778b91 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskStatusRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/TaskStatusRepositoryTest.java @@ -47,6 +47,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; @SpringBootTest( classes = {org.apache.airavata.config.JpaConfig.class, TaskStatusRepositoryTest.TestConfiguration.class}, @@ -55,6 +56,7 @@ import org.springframework.test.context.TestPropertySource; "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class TaskStatusRepositoryTest extends TestBase { @Configuration diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/UserRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/UserRepositoryTest.java index 2edc4d07fb..6fbcb55fc6 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/UserRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/expcatalog/UserRepositoryTest.java @@ -42,6 +42,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; @SpringBootTest( classes = {org.apache.airavata.config.JpaConfig.class, UserRepositoryTest.TestConfiguration.class}, @@ -50,6 +51,7 @@ import org.springframework.test.context.TestPropertySource; "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class UserRepositoryTest extends TestBase { @Configuration diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/replicacatalog/DataProductRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/replicacatalog/DataProductRepositoryTest.java index 5f0f8bcbc1..411cd7695c 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/replicacatalog/DataProductRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/replicacatalog/DataProductRepositoryTest.java @@ -36,13 +36,51 @@ import org.apache.airavata.registry.exceptions.ReplicaCatalogException; import org.apache.airavata.registry.repositories.common.TestBase; import org.apache.airavata.registry.services.DataProductService; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; - -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, DataProductRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class DataProductRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final DataProductService dataProductService; private String gatewayId = "testGateway"; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/replicacatalog/DataReplicaLocationRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/replicacatalog/DataReplicaLocationRepositoryTest.java index 652ea01a74..dc6c8028b3 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/replicacatalog/DataReplicaLocationRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/replicacatalog/DataReplicaLocationRepositoryTest.java @@ -36,13 +36,51 @@ import org.apache.airavata.registry.repositories.common.TestBase; import org.apache.airavata.registry.services.DataProductService; import org.apache.airavata.registry.services.DataReplicaLocationService; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; - -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +import org.springframework.test.context.TestConstructor; + +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, DataReplicaLocationRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class DataReplicaLocationRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final DataProductService dataProductService; private final DataReplicaLocationService dataReplicaLocationService; diff --git a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/workflowcatalog/WorkflowRepositoryTest.java b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/workflowcatalog/WorkflowRepositoryTest.java index 3f78485e3d..15751688c2 100644 --- a/airavata-api/src/test/java/org/apache/airavata/registry/repositories/workflowcatalog/WorkflowRepositoryTest.java +++ b/airavata-api/src/test/java/org/apache/airavata/registry/repositories/workflowcatalog/WorkflowRepositoryTest.java @@ -27,15 +27,53 @@ import org.apache.airavata.registry.repositories.common.TestBase; import org.apache.airavata.registry.services.WorkflowService; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.TestConstructor; // TODO: fix derby initialization script so that this test can be re-enabled @Disabled -@SpringBootTest(classes = {org.apache.airavata.config.JpaConfig.class}) +@SpringBootTest( + classes = {org.apache.airavata.config.JpaConfig.class, WorkflowRepositoryTest.TestConfiguration.class}, + properties = { + "spring.main.allow-bean-definition-overriding=true", + "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration" + }) @TestPropertySource(locations = "classpath:airavata.properties") +@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) public class WorkflowRepositoryTest extends TestBase { + @Configuration + @ComponentScan( + basePackages = {"org.apache.airavata.service", "org.apache.airavata.registry", "org.apache.airavata.config"}, + excludeFilters = { + @ComponentScan.Filter( + type = FilterType.ASSIGNABLE_TYPE, + classes = { + org.apache.airavata.config.BackgroundServicesLauncher.class, + org.apache.airavata.config.ThriftServerLauncher.class, + org.apache.airavata.monitor.realtime.RealtimeMonitor.class, + org.apache.airavata.monitor.email.EmailBasedMonitor.class, + org.apache.airavata.monitor.cluster.ClusterStatusMonitorJob.class, + org.apache.airavata.monitor.AbstractMonitor.class, + org.apache.airavata.helix.impl.controller.HelixController.class, + org.apache.airavata.helix.impl.participant.GlobalParticipant.class, + org.apache.airavata.helix.impl.workflow.PreWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.PostWorkflowManager.class, + org.apache.airavata.helix.impl.workflow.ParserWorkflowManager.class + }), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.monitor\\..*"), + @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org\\.apache\\.airavata\\.helix\\..*") + }) + @EnableConfigurationProperties(org.apache.airavata.config.AiravataServerProperties.class) + @Import(org.apache.airavata.config.AiravataPropertiesConfiguration.class) + static class TestConfiguration {} + private final WorkflowService workflowService; public WorkflowRepositoryTest(WorkflowService workflowService) {
