Search in sources :

Example 1 with AwsBatchDescribeJobsCache

use of pipelite.executor.describe.cache.AwsBatchDescribeJobsCache in project pipelite by enasequence.

the class AwsBatchDescribeJobsCacheTest method test.

@Test
public void test() {
    AwsBatchDescribeJobsCache cache = new AwsBatchDescribeJobsCache(Mockito.mock(ServiceConfiguration.class), Mockito.mock(InternalErrorService.class));
    AwsBatchExecutorParameters region1 = AwsBatchExecutorParameters.builder().region("1").build();
    AwsBatchExecutorParameters region2 = AwsBatchExecutorParameters.builder().region("2").build();
    AwsBatchExecutor executor1Region1 = new AwsBatchExecutor();
    AwsBatchExecutor executor2Region1 = new AwsBatchExecutor();
    AwsBatchExecutor executor3Region2 = new AwsBatchExecutor();
    AwsBatchExecutor executor4Region1 = new AwsBatchExecutor();
    executor1Region1.setExecutorParams(region1);
    executor2Region1.setExecutorParams(region1);
    executor3Region2.setExecutorParams(region2);
    executor4Region1.setExecutorParams(region1);
    assertThat(cache.getCacheContext(executor1Region1).getRegion()).isEqualTo(region1.getRegion());
    assertThat(cache.getCacheContext(executor2Region1).getRegion()).isEqualTo(region1.getRegion());
    assertThat(cache.getCacheContext(executor3Region2).getRegion()).isEqualTo(region2.getRegion());
    assertThat(cache.getCacheContext(executor4Region1).getRegion()).isEqualTo(region1.getRegion());
    DescribeJobs<String, AwsBatchDescribeJobsCache.ExecutorContext> describeJobs1 = cache.getDescribeJobs(executor1Region1);
    DescribeJobs<String, AwsBatchDescribeJobsCache.ExecutorContext> describeJobs2 = cache.getDescribeJobs(executor2Region1);
    DescribeJobs<String, AwsBatchDescribeJobsCache.ExecutorContext> describeJobs3 = cache.getDescribeJobs(executor3Region2);
    DescribeJobs<String, AwsBatchDescribeJobsCache.ExecutorContext> describeJobs4 = cache.getDescribeJobs(executor4Region1);
    assertThat(describeJobs1 == describeJobs2).isTrue();
    assertThat(describeJobs1 != describeJobs3).isTrue();
    assertThat(describeJobs1 == describeJobs4).isTrue();
}
Also used : AwsBatchDescribeJobsCache(pipelite.executor.describe.cache.AwsBatchDescribeJobsCache) ServiceConfiguration(pipelite.configuration.ServiceConfiguration) AwsBatchExecutor(pipelite.executor.AwsBatchExecutor) InternalErrorService(pipelite.service.InternalErrorService) AwsBatchExecutorParameters(pipelite.stage.parameters.AwsBatchExecutorParameters) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 ServiceConfiguration (pipelite.configuration.ServiceConfiguration)1 AwsBatchExecutor (pipelite.executor.AwsBatchExecutor)1 AwsBatchDescribeJobsCache (pipelite.executor.describe.cache.AwsBatchDescribeJobsCache)1 InternalErrorService (pipelite.service.InternalErrorService)1 AwsBatchExecutorParameters (pipelite.stage.parameters.AwsBatchExecutorParameters)1