Search in sources :

Example 1 with DescribeClusterResult

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

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

the class EmrDaoTest method getEmrClusterStatusByIdAssertReturnNullWhenClusterIsNull.

@Test
public void getEmrClusterStatusByIdAssertReturnNullWhenClusterIsNull() throws Exception {
    String clusterId = "clusterId";
    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());
            return new DescribeClusterResult();
        }
    });
    assertNull(emrDao.getEmrClusterStatusById(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) Test(org.junit.Test)

Example 3 with DescribeClusterResult

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

the class EmrDaoTest method getEmrClusterByIdAssertReturnNullWhenDescribeClusterResponseClusterIsNull.

@Test
public void getEmrClusterByIdAssertReturnNullWhenDescribeClusterResponseClusterIsNull() throws Exception {
    String clusterId = "clusterId";
    when(mockEmrOperations.describeClusterRequest(any(), any())).thenReturn(new DescribeClusterResult());
    assertNull(emrDao.getEmrClusterById(clusterId, new AwsParamsDto()));
}
Also used : AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) DescribeClusterResult(com.amazonaws.services.elasticmapreduce.model.DescribeClusterResult) Test(org.junit.Test)

Example 4 with DescribeClusterResult

use of com.amazonaws.services.elasticmapreduce.model.DescribeClusterResult 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()));
}
Also used : ClusterState(com.amazonaws.services.elasticmapreduce.model.ClusterState) 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) ClusterStatus(com.amazonaws.services.elasticmapreduce.model.ClusterStatus) Test(org.junit.Test)

Aggregations

DescribeClusterResult (com.amazonaws.services.elasticmapreduce.model.DescribeClusterResult)4 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)4 Test (org.junit.Test)4 DescribeClusterRequest (com.amazonaws.services.elasticmapreduce.model.DescribeClusterRequest)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Cluster (com.amazonaws.services.elasticmapreduce.model.Cluster)2 ClusterState (com.amazonaws.services.elasticmapreduce.model.ClusterState)1 ClusterStatus (com.amazonaws.services.elasticmapreduce.model.ClusterStatus)1