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);
}
}
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()));
}
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);
}
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);
}
}
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);
}
}
Aggregations