use of com.amazonaws.services.elasticmapreduce.model.ClusterState in project herd by FINRAOS.
the class EmrHelperTest method testGetActiveEmrClusterIdAssertErrorWhenClusterIdSpecifiedAndClusterStateNotActive.
@Test
public void testGetActiveEmrClusterIdAssertErrorWhenClusterIdSpecifiedAndClusterStateNotActive() {
EmrDao originalEmrDao = emrHelper.getEmrDao();
EmrDao mockEmrDao = mock(EmrDao.class);
emrHelper.setEmrDao(mockEmrDao);
try {
String emrClusterId = "emrClusterId";
String emrClusterName = "emrClusterName";
String expectedEmrClusterId = "expectedEmrClusterId";
ClusterState actualClusterState = ClusterState.TERMINATED;
when(mockEmrDao.getEmrClusterById(any(), any())).thenReturn(new Cluster().withId(expectedEmrClusterId).withName(emrClusterName).withStatus(new ClusterStatus().withState(actualClusterState)));
try {
emrHelper.getActiveEmrClusterId(emrClusterId, emrClusterName, null);
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("The cluster with ID \"%s\" is not active. The cluster state must be in one of [STARTING, BOOTSTRAPPING, RUNNING, " + "WAITING]. Current state is \"%s\"", emrClusterId, actualClusterState), e.getMessage());
}
verify(mockEmrDao).getEmrClusterById(eq(emrClusterId), any());
verifyNoMoreInteractions(mockEmrDao);
} finally {
emrHelper.setEmrDao(originalEmrDao);
}
}
use of com.amazonaws.services.elasticmapreduce.model.ClusterState in project herd by FINRAOS.
the class EmrDaoTest method getEmrClusterStatusByIdAssertReturnClusterState.
@Test
public void getEmrClusterStatusByIdAssertReturnClusterState() throws Exception {
String clusterId = "clusterId";
ClusterState expectedState = ClusterState.BOOTSTRAPPING;
when(mockEmrOperations.describeClusterRequest(any(), any())).then(new Answer<DescribeClusterResult>() {
@Override
public DescribeClusterResult answer(InvocationOnMock invocation) throws Throwable {
DescribeClusterRequest describeClusterRequest = invocation.getArgument(1);
assertEquals(clusterId, describeClusterRequest.getClusterId());
DescribeClusterResult describeClusterResult = new DescribeClusterResult();
Cluster cluster = new Cluster();
ClusterStatus status = new ClusterStatus();
status.setState(expectedState);
cluster.setStatus(status);
describeClusterResult.setCluster(cluster);
return describeClusterResult;
}
});
assertEquals(expectedState.toString(), emrDao.getEmrClusterStatusById(clusterId, new AwsParamsDto()));
}
Aggregations