Search in sources :

Example 1 with Cluster

use of com.amazonaws.services.elasticmapreduce.model.Cluster in project herd by FINRAOS.

the class EmrHelperTest method testGetActiveEmrClusterIdAssertReturnActualClusterIdWhenClusterIdSpecifiedAndClusterStateActiveAndNameMatch.

@Test
public void testGetActiveEmrClusterIdAssertReturnActualClusterIdWhenClusterIdSpecifiedAndClusterStateActiveAndNameMatch() {
    EmrDao originalEmrDao = emrHelper.getEmrDao();
    EmrDao mockEmrDao = mock(EmrDao.class);
    emrHelper.setEmrDao(mockEmrDao);
    try {
        String emrClusterId = "emrClusterId";
        String emrClusterName = "emrClusterName";
        String expectedEmrClusterId = "expectedEmrClusterId";
        when(mockEmrDao.getEmrClusterById(any(), any())).thenReturn(new Cluster().withId(expectedEmrClusterId).withName(emrClusterName).withStatus(new ClusterStatus().withState(ClusterState.RUNNING)));
        assertEquals(expectedEmrClusterId, emrHelper.getActiveEmrClusterId(emrClusterId, emrClusterName, null));
        verify(mockEmrDao).getEmrClusterById(eq(emrClusterId.trim()), any());
        verifyNoMoreInteractions(mockEmrDao);
    } finally {
        emrHelper.setEmrDao(originalEmrDao);
    }
}
Also used : Cluster(com.amazonaws.services.elasticmapreduce.model.Cluster) EmrDao(org.finra.herd.dao.EmrDao) ClusterStatus(com.amazonaws.services.elasticmapreduce.model.ClusterStatus) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Example 2 with Cluster

use of com.amazonaws.services.elasticmapreduce.model.Cluster in project herd by FINRAOS.

the class EmrDaoTest method getEmrClusterByIdAssertCallDescribeCluster.

@Test
public void getEmrClusterByIdAssertCallDescribeCluster() throws Exception {
    String clusterId = "clusterId";
    Cluster expectedCluster = new Cluster();
    when(mockEmrOperations.describeClusterRequest(any(), any())).thenAnswer(new Answer<DescribeClusterResult>() {

        @Override
        public DescribeClusterResult answer(InvocationOnMock invocation) throws Throwable {
            DescribeClusterRequest describeClusterRequest = invocation.getArgument(1);
            assertEquals(clusterId, describeClusterRequest.getClusterId());
            DescribeClusterResult describeClusterResult = new DescribeClusterResult();
            describeClusterResult.setCluster(expectedCluster);
            return describeClusterResult;
        }
    });
    assertEquals(expectedCluster, emrDao.getEmrClusterById(clusterId, new AwsParamsDto()));
}
Also used : AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) DescribeClusterRequest(com.amazonaws.services.elasticmapreduce.model.DescribeClusterRequest) DescribeClusterResult(com.amazonaws.services.elasticmapreduce.model.DescribeClusterResult) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Cluster(com.amazonaws.services.elasticmapreduce.model.Cluster) Test(org.junit.Test)

Example 3 with Cluster

use of com.amazonaws.services.elasticmapreduce.model.Cluster in project herd by FINRAOS.

the class EmrHelperTest method testGetEmrClusterByIdNull.

@Test
public void testGetEmrClusterByIdNull() throws Exception {
    Cluster cluster = emrDao.getEmrClusterById(null, null);
    assertNull(cluster);
}
Also used : EmrCluster(org.finra.herd.model.api.xml.EmrCluster) Cluster(com.amazonaws.services.elasticmapreduce.model.Cluster) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 4 with Cluster

use of com.amazonaws.services.elasticmapreduce.model.Cluster in project herd by FINRAOS.

the class EmrHelperTest method testGetActiveEmrClusterIdAssertParametersCaseIgnored.

@Test
public void testGetActiveEmrClusterIdAssertParametersCaseIgnored() {
    EmrDao originalEmrDao = emrHelper.getEmrDao();
    EmrDao mockEmrDao = mock(EmrDao.class);
    emrHelper.setEmrDao(mockEmrDao);
    try {
        String emrClusterId = "emrClusterId";
        String emrClusterName = "emrClusterName";
        String expectedEmrClusterId = "expectedEmrClusterId";
        when(mockEmrDao.getEmrClusterById(any(), any())).thenReturn(new Cluster().withId(expectedEmrClusterId).withName(emrClusterName).withStatus(new ClusterStatus().withState(ClusterState.RUNNING)));
        assertEquals(expectedEmrClusterId, emrHelper.getActiveEmrClusterId(StringUtils.upperCase(emrClusterId), StringUtils.upperCase(emrClusterName), null));
        verify(mockEmrDao).getEmrClusterById(eq(StringUtils.upperCase(emrClusterId)), any());
        verifyNoMoreInteractions(mockEmrDao);
    } finally {
        emrHelper.setEmrDao(originalEmrDao);
    }
}
Also used : Cluster(com.amazonaws.services.elasticmapreduce.model.Cluster) EmrDao(org.finra.herd.dao.EmrDao) ClusterStatus(com.amazonaws.services.elasticmapreduce.model.ClusterStatus) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Example 5 with Cluster

use of com.amazonaws.services.elasticmapreduce.model.Cluster in project herd by FINRAOS.

the class EmrHelperTest method testGetActiveEmrClusterIdAssertReturnActualClusterIdWhenClusterStateActiveAndNameNotSpecified.

@Test
public void testGetActiveEmrClusterIdAssertReturnActualClusterIdWhenClusterStateActiveAndNameNotSpecified() {
    EmrDao originalEmrDao = emrHelper.getEmrDao();
    EmrDao mockEmrDao = mock(EmrDao.class);
    emrHelper.setEmrDao(mockEmrDao);
    try {
        String emrClusterId = "emrClusterId";
        String emrClusterName = null;
        String expectedEmrClusterId = "expectedEmrClusterId";
        String actualEmrClusterName = "actualEmrClusterName";
        when(mockEmrDao.getEmrClusterById(any(), any())).thenReturn(new Cluster().withId(expectedEmrClusterId).withName(actualEmrClusterName).withStatus(new ClusterStatus().withState(ClusterState.RUNNING)));
        assertEquals(expectedEmrClusterId, emrHelper.getActiveEmrClusterId(emrClusterId, emrClusterName, null));
        verify(mockEmrDao).getEmrClusterById(eq(emrClusterId), any());
        verifyNoMoreInteractions(mockEmrDao);
    } finally {
        emrHelper.setEmrDao(originalEmrDao);
    }
}
Also used : Cluster(com.amazonaws.services.elasticmapreduce.model.Cluster) EmrDao(org.finra.herd.dao.EmrDao) ClusterStatus(com.amazonaws.services.elasticmapreduce.model.ClusterStatus) Test(org.junit.Test) AbstractDaoTest(org.finra.herd.dao.AbstractDaoTest)

Aggregations

Cluster (com.amazonaws.services.elasticmapreduce.model.Cluster)11 Test (org.junit.Test)9 ClusterStatus (com.amazonaws.services.elasticmapreduce.model.ClusterStatus)7 AbstractDaoTest (org.finra.herd.dao.AbstractDaoTest)6 EmrDao (org.finra.herd.dao.EmrDao)6 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)4 ClusterState (com.amazonaws.services.elasticmapreduce.model.ClusterState)2 ClusterSummary (com.amazonaws.services.elasticmapreduce.model.ClusterSummary)2 DescribeClusterRequest (com.amazonaws.services.elasticmapreduce.model.DescribeClusterRequest)2 DescribeClusterResult (com.amazonaws.services.elasticmapreduce.model.DescribeClusterResult)2 EmrCluster (org.finra.herd.model.api.xml.EmrCluster)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 ListInstanceFleetsResult (com.amazonaws.services.elasticmapreduce.model.ListInstanceFleetsResult)1 Step (com.amazonaws.services.elasticmapreduce.model.Step)1 StepSummary (com.amazonaws.services.elasticmapreduce.model.StepSummary)1 EmrStep (org.finra.herd.model.api.xml.EmrStep)1 EmrClusterDefinitionEntity (org.finra.herd.model.jpa.EmrClusterDefinitionEntity)1 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)1 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)1