use of org.finra.herd.model.dto.AwsParamsDto 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()));
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoTest method getClusterStepAssertCallsDescribeStepAndReturnsStep.
@Test
public void getClusterStepAssertCallsDescribeStepAndReturnsStep() throws Exception {
String clusterId = "clusterId";
String stepId = "stepId";
Step expectedStep = new Step();
when(mockEmrOperations.describeStepRequest(any(), any())).then(new Answer<DescribeStepResult>() {
@Override
public DescribeStepResult answer(InvocationOnMock invocation) throws Throwable {
DescribeStepRequest describeStepRequest = invocation.getArgument(1);
assertEquals(clusterId, describeStepRequest.getClusterId());
assertEquals(stepId, describeStepRequest.getStepId());
DescribeStepResult describeStepResult = new DescribeStepResult();
describeStepResult.setStep(expectedStep);
return describeStepResult;
}
});
assertEquals(expectedStep, emrDao.getClusterStep(clusterId, stepId, new AwsParamsDto()));
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoTest method getActiveEmrClusterByNameAssertUsesListMarker.
@Test
public void getActiveEmrClusterByNameAssertUsesListMarker() throws Exception {
String clusterName = "clusterName";
String expectedClusterId = "clusterId";
when(mockEmrOperations.listEmrClusters(any(), any())).then(new Answer<ListClustersResult>() {
@Override
public ListClustersResult answer(InvocationOnMock invocation) throws Throwable {
ListClustersRequest listClustersRequest = invocation.getArgument(1);
String marker = listClustersRequest.getMarker();
ListClustersResult listClustersResult = new ListClustersResult();
listClustersResult.setClusters(new ArrayList<>());
/*
* When no marker is given, this is the request for the first page.
* Return a known marker. The expectation is that the next call to this method should have a request with this expected marker.
*/
if (marker == null) {
listClustersResult.setMarker("pagination_marker");
} else /*
* When a marker is given, this is expected to be the subsequent call.
*/
{
// Assert that the correct marker is passed in
assertEquals("pagination_marker", marker);
ClusterSummary clusterSummary = new ClusterSummary();
clusterSummary.setId(expectedClusterId);
clusterSummary.setName(clusterName);
listClustersResult.getClusters().add(clusterSummary);
}
return listClustersResult;
}
});
ClusterSummary result = emrDao.getActiveEmrClusterByName(clusterName, new AwsParamsDto());
assertNotNull(result);
assertEquals(expectedClusterId, result.getId());
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoTest method terminateEmrCluster.
@Test
public void terminateEmrCluster() throws Exception {
String clusterName = "clusterName";
boolean overrideTerminationProtection = false;
String clusterId = "clusterId";
ListClustersResult listClustersResult = new ListClustersResult();
listClustersResult.setClusters(new ArrayList<>());
ClusterSummary clusterSummary = new ClusterSummary();
clusterSummary.setId(clusterId);
clusterSummary.setName(clusterName);
listClustersResult.getClusters().add(clusterSummary);
when(mockEmrOperations.listEmrClusters(any(), any())).thenReturn(listClustersResult);
emrDao.terminateEmrCluster(clusterId, overrideTerminationProtection, new AwsParamsDto());
// Assert that terminateEmrCluster was called with these parameters ONCE
verify(mockEmrOperations).terminateEmrCluster(any(), eq(clusterId), eq(overrideTerminationProtection));
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoTest method getClusterActiveStepAssertReturnFirstWhenStepListSizeGt1.
@Test
public void getClusterActiveStepAssertReturnFirstWhenStepListSizeGt1() throws Exception {
String clusterId = "clusterId";
StepSummary expectedStepSummary = new StepSummary();
expectedStepSummary.setId("expected");
ListStepsResult listStepsResult = new ListStepsResult();
listStepsResult.setSteps(Arrays.asList(expectedStepSummary, new StepSummary()));
when(mockEmrOperations.listStepsRequest(any(), any())).thenReturn(listStepsResult);
assertEquals(expectedStepSummary, emrDao.getClusterActiveStep(clusterId, new AwsParamsDto()));
}
Aggregations