Search in sources :

Example 1 with ApiCommand

use of com.sequenceiq.mock.swagger.model.ApiCommand in project cloudbreak by hortonworks.

the class ClouderaManagerResourceOperation method importClusterTemplate.

public ResponseEntity<ApiCommand> importClusterTemplate(String mockUuid, @Valid Boolean addRepositories, @Valid ApiClusterTemplate body) {
    clouderaManagerStoreService.importClusterTemplate(mockUuid, body);
    ApiCommand response = new ApiCommand().id(Integer.valueOf(1)).name("Import ClusterTemplate").active(Boolean.TRUE);
    return ResponseEntity.ok(response);
}
Also used : ApiCommand(com.sequenceiq.mock.swagger.model.ApiCommand)

Example 2 with ApiCommand

use of com.sequenceiq.mock.swagger.model.ApiCommand in project cloudbreak by hortonworks.

the class DataProviderService method getSuccessfulApiCommand.

public ApiCommand getSuccessfulApiCommand(Integer id) {
    ApiCommand result = new ApiCommand();
    result.setId(id);
    result.setActive(false);
    result.setSuccess(true);
    return result;
}
Also used : ApiCommand(com.sequenceiq.mock.swagger.model.ApiCommand)

Example 3 with ApiCommand

use of com.sequenceiq.mock.swagger.model.ApiCommand in project cloudbreak by hortonworks.

the class ClusterResourceOperation method stopCommand.

public ResponseEntity<ApiCommand> stopCommand(String mockUuid, String clusterName) {
    ClouderaManagerDto read = clouderaManagerStoreService.read(mockUuid);
    Map<String, ApiServiceState> newStates = new HashMap<>();
    read.getServiceStates().forEach((service, apiServiceState) -> newStates.put(service, ApiServiceState.STOPPED));
    read.setServiceStates(newStates);
    read.setStatus(ApiServiceState.STOPPED);
    return responseCreatorComponent.exec(new ApiCommand().id(CommandId.CLUSTER_STOP).active(Boolean.TRUE).name("Stop"));
}
Also used : ClouderaManagerDto(com.sequenceiq.mock.clouderamanager.ClouderaManagerDto) ApiCommand(com.sequenceiq.mock.swagger.model.ApiCommand) ApiServiceState(com.sequenceiq.mock.swagger.model.ApiServiceState) HashMap(java.util.HashMap)

Example 4 with ApiCommand

use of com.sequenceiq.mock.swagger.model.ApiCommand in project cloudbreak by hortonworks.

the class ClusterResourceOperation method startCommand.

public ResponseEntity<ApiCommand> startCommand(String mockUuid, String clusterName) {
    ClouderaManagerDto read = clouderaManagerStoreService.read(mockUuid);
    Map<String, ApiServiceState> newStates = new HashMap<>();
    read.getServiceStates().forEach((service, apiServiceState) -> newStates.put(service, ApiServiceState.STARTED));
    read.setServiceStates(newStates);
    read.setStatus(ApiServiceState.STARTED);
    return responseCreatorComponent.exec(new ApiCommand().id(CommandId.CLUSTER_START).active(Boolean.TRUE).name("Start"));
}
Also used : ClouderaManagerDto(com.sequenceiq.mock.clouderamanager.ClouderaManagerDto) ApiCommand(com.sequenceiq.mock.swagger.model.ApiCommand) ApiServiceState(com.sequenceiq.mock.swagger.model.ApiServiceState) HashMap(java.util.HashMap)

Example 5 with ApiCommand

use of com.sequenceiq.mock.swagger.model.ApiCommand in project cloudbreak by hortonworks.

the class ResponseModifierServiceTest method testEvaluateResponseWhenTransformResponsePackage.

@Test
public void testEvaluateResponseWhenTransformResponsePackage() throws Throwable {
    MockResponse mockResponse1 = createMockResponse(0, 200, "/path1", "get", null, new ApiCommand().id(Integer.valueOf(1)));
    mockResponse1.setClss("com.cloudera.api.swagger.model.ApiCommand");
    underTest.addResponse(mockResponse1);
    ApiCommand actualPost = underTest.evaluateResponse("get_/path1", ApiCommand.class, () -> null);
    assertEquals(actualPost.getId(), Integer.valueOf(1));
}
Also used : MockResponse(com.sequenceiq.mock.spi.MockResponse) ApiCommand(com.sequenceiq.mock.swagger.model.ApiCommand) Test(org.junit.jupiter.api.Test)

Aggregations

ApiCommand (com.sequenceiq.mock.swagger.model.ApiCommand)5 ClouderaManagerDto (com.sequenceiq.mock.clouderamanager.ClouderaManagerDto)2 ApiServiceState (com.sequenceiq.mock.swagger.model.ApiServiceState)2 HashMap (java.util.HashMap)2 MockResponse (com.sequenceiq.mock.spi.MockResponse)1 Test (org.junit.jupiter.api.Test)1