Search in sources :

Example 1 with ClusterStatus

use of com.amazonaws.services.elasticmapreduce.model.ClusterStatus 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 ClusterStatus

use of com.amazonaws.services.elasticmapreduce.model.ClusterStatus 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 3 with ClusterStatus

use of com.amazonaws.services.elasticmapreduce.model.ClusterStatus 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)

Example 4 with ClusterStatus

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

the class EmrHelperTest method testGetActiveEmrClusterIdAssertErrorWhenClusterIdSpecifiedAndNameMismatch.

@Test
public void testGetActiveEmrClusterIdAssertErrorWhenClusterIdSpecifiedAndNameMismatch() {
    EmrDao originalEmrDao = emrHelper.getEmrDao();
    EmrDao mockEmrDao = mock(EmrDao.class);
    emrHelper.setEmrDao(mockEmrDao);
    try {
        String emrClusterId = "emrClusterId";
        String emrClusterName = "emrClusterName";
        String expectedEmrClusterId = "expectedEmrClusterId";
        String actualEmrClusterName = "actualEmrClusterName";
        when(mockEmrDao.getEmrClusterById(any(), any())).thenReturn(new Cluster().withId(expectedEmrClusterId).withName(actualEmrClusterName).withStatus(new ClusterStatus().withState(ClusterState.RUNNING)));
        try {
            emrHelper.getActiveEmrClusterId(emrClusterId, emrClusterName, null);
            fail();
        } catch (IllegalArgumentException e) {
            assertEquals(String.format("The cluster with ID \"%s\" does not match the expected name \"%s\". The actual name is \"%s\".", expectedEmrClusterId, emrClusterName, actualEmrClusterName), e.getMessage());
        }
        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 5 with ClusterStatus

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

the class EmrHelperTest method testGetActiveEmrClusterIdAssertParametersTrimmed.

@Test
public void testGetActiveEmrClusterIdAssertParametersTrimmed() {
    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.wrap(emrClusterId, BLANK_TEXT), StringUtils.wrap(emrClusterName, BLANK_TEXT), 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)

Aggregations

ClusterStatus (com.amazonaws.services.elasticmapreduce.model.ClusterStatus)8 Cluster (com.amazonaws.services.elasticmapreduce.model.Cluster)7 Test (org.junit.Test)7 AbstractDaoTest (org.finra.herd.dao.AbstractDaoTest)6 EmrDao (org.finra.herd.dao.EmrDao)6 ClusterState (com.amazonaws.services.elasticmapreduce.model.ClusterState)2 ClusterStateChangeReason (com.amazonaws.services.elasticmapreduce.model.ClusterStateChangeReason)1 ClusterSummary (com.amazonaws.services.elasticmapreduce.model.ClusterSummary)1 ClusterTimeline (com.amazonaws.services.elasticmapreduce.model.ClusterTimeline)1 DescribeClusterRequest (com.amazonaws.services.elasticmapreduce.model.DescribeClusterRequest)1 DescribeClusterResult (com.amazonaws.services.elasticmapreduce.model.DescribeClusterResult)1 ListClustersResult (com.amazonaws.services.elasticmapreduce.model.ListClustersResult)1 ArrayList (java.util.ArrayList)1 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1