public StepSummary unmarshall(JsonUnmarshallerContext context) throws Exception { StepSummary stepSummary = new StepSummary();
@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, getAwsParamsDto())); }
@Test public void getClusterActiveStepAssertCallListStepsAndReturnStepSummary() throws Exception { String clusterId = "clusterId"; StepSummary expectedStepSummary = new StepSummary(); when(mockEmrOperations.listStepsRequest(any(), any())).then(new Answer<ListStepsResult>() { @Override public ListStepsResult answer(InvocationOnMock invocation) throws Throwable { ListStepsRequest listStepsRequest = invocation.getArgument(1); assertEquals(clusterId, listStepsRequest.getClusterId()); assertEquals(1, listStepsRequest.getStepStates().size()); assertEquals(StepState.RUNNING.toString(), listStepsRequest.getStepStates().get(0)); ListStepsResult listStepsResult = new ListStepsResult(); listStepsResult.setSteps(new ArrayList<>()); listStepsResult.getSteps().add(expectedStepSummary); return listStepsResult; } }); assertEquals(expectedStepSummary, emrDao.getClusterActiveStep(clusterId, getAwsParamsDto())); }
public StepSummary unmarshall(JsonUnmarshallerContext context) throws Exception { StepSummary stepSummary = new StepSummary();
@Override public ListStepsResult listStepsRequest(AmazonElasticMapReduceClient emrClient, ListStepsRequest listStepsRequest) { MockEmrJobFlow cluster = getClusterById(listStepsRequest.getClusterId()); if (cluster == null) { throw new AmazonServiceException("No cluster found with jobFlowId: " + listStepsRequest.getClusterId()); } List<StepSummary> steps = new ArrayList<>(); // Add steps that are in these states for (MockEmrJobFlow step : cluster.getSteps()) { if ((listStepsRequest.getStepStates() == null || listStepsRequest.getStepStates().isEmpty()) || listStepsRequest.getStepStates().contains(step.getStatus())) { StepSummary stepSummary = new StepSummary().withId(step.getJobFlowId()).withName(step.getJobFlowName()).withStatus(new StepStatus().withState(step.getStatus())) .withConfig(new HadoopStepConfig().withJar(step.getJarLocation())); steps.add(stepSummary); } } return new ListStepsResult().withSteps(steps); }