Package com.sequenceiq.cloudbreak.controller.json

Examples of com.sequenceiq.cloudbreak.controller.json.ClusterResponse


        cluster.setEmailNeeded(clusterRequest.getEmailNeeded());
        return cluster;
    }

    public ClusterResponse convert(Cluster cluster, String clusterJson) {
        ClusterResponse clusterResponse = new ClusterResponse();
        clusterResponse.setCluster(jsonHelper.createJsonFromString(clusterJson));
        clusterResponse.setId(cluster.getId());
        clusterResponse.setStatus(cluster.getStatus().name());
        if (cluster.getCreationFinished() != null) {
            long now = new Date().getTime();
            long createFinished = now - cluster.getCreationFinished();
            int minutes = (int) ((createFinished / (MILLIS_PER_SECOND * SECONDS_PER_MINUTE)) % SECONDS_PER_MINUTE);
            int hours = (int) (createFinished / (MILLIS_PER_SECOND * SECONDS_PER_MINUTE * SECONDS_PER_MINUTE));
            clusterResponse.setHoursUp(hours);
            clusterResponse.setMinutesUp(minutes);
        } else {
            clusterResponse.setHoursUp(0);
            clusterResponse.setMinutesUp(0);
        }
        clusterResponse.setStatusReason(cluster.getStatusReason());
        clusterResponse.setBlueprintId(cluster.getBlueprint().getId());
        clusterResponse.setDescription(cluster.getDescription() == null ? "" : cluster.getDescription());
        return clusterResponse;
    }
View Full Code Here


        stackJson.setHash(entity.getHash());
        stackJson.setMetadata(metaDataConverter.convertAllEntityToJson(entity.getInstanceMetaData()));
        if (entity.getCluster() != null) {
            stackJson.setCluster(clusterConverter.convert(entity.getCluster(), "{}"));
        } else {
            stackJson.setCluster(new ClusterResponse());
        }
        return stackJson;
    }
View Full Code Here

        stackJson.setMetadata(metaDataConverter.convertAllEntityToJson(entity.getInstanceMetaData()));
        stackJson.setAmbariServerIp(entity.getAmbariIp());
        if (entity.getCluster() != null) {
            stackJson.setCluster(clusterConverter.convert(entity.getCluster(), "{}"));
        } else {
            stackJson.setCluster(new ClusterResponse());
        }
        return stackJson;
    }
View Full Code Here

    @ResponseBody
    public ResponseEntity<ClusterResponse> retrieveCluster(@PathVariable Long stackId) {
        Stack stack = stackService.get(stackId);
        Cluster cluster = clusterService.retrieveCluster(stackId);
        String clusterJson = clusterService.getClusterJson(stack.getAmbariIp(), stackId);
        ClusterResponse response = clusterConverter.convert(cluster, clusterJson);
        return new ResponseEntity<>(response, HttpStatus.OK);
    }
View Full Code Here

    @Test
    public void testConvertClusterJsonToEntity() {
        // GIVEN
        given(jsonHelper.createJsonFromString(DUMMY_JSON)).willReturn(jsonNode);
        // WHEN
        ClusterResponse response = underTest.convert(cluster, DUMMY_JSON);
        // THEN
        assertEquals(response.getStatus(), cluster.getStatus().toString());
        assertEquals(response.getBlueprintId(), cluster.getBlueprint().getId());
        assertEquals(response.getDescription(), cluster.getDescription());
    }
View Full Code Here

    public void testConvertClusterJsonToEntityWhenCreationFinishedIsNull() {
        // GIVEN
        cluster.setCreationFinished(null);
        given(jsonHelper.createJsonFromString(DUMMY_JSON)).willReturn(jsonNode);
        // WHEN
        ClusterResponse response = underTest.convert(cluster, DUMMY_JSON);
        // THEN
        assertEquals(response.getHoursUp(), 0L);
        assertEquals(response.getMinutesUp(), 0L);
    }
View Full Code Here

    public void testConvertClusterJsonToEntityWheDescriptionIsNull() {
        // GIVEN
        cluster.setDescription(null);
        given(jsonHelper.createJsonFromString(DUMMY_JSON)).willReturn(jsonNode);
        // WHEN
        ClusterResponse response = underTest.convert(cluster, DUMMY_JSON);
        // THEN
        assertEquals(response.getDescription(), "");
    }
View Full Code Here

        underTest = new AmbariClusterService();
        MockitoAnnotations.initMocks(this);
        cluster = createCluster();
        stack = createStack(cluster);
        clusterRequest = new ClusterRequest();
        clusterResponse = new ClusterResponse();
        given(stackRepository.findById(anyLong())).willReturn(stack);
        given(stackRepository.findOneWithLists(anyLong())).willReturn(stack);
    }
View Full Code Here

    private StackJson createStackJson() {
        StackJson stackJson = new StackJson();
        stackJson.setId(DUMMY_ID);
        stackJson.setAmbariServerIp(AMBARI_IP);
        stackJson.setCloudPlatform(CloudPlatform.AWS);
        stackJson.setCluster(new ClusterResponse());
        stackJson.setCredentialId(DUMMY_ID);
        stackJson.setHash(DUMMY_HASH);
        stackJson.setPublicInAccount(false);
        stackJson.setAccount(DUMMY_HASH);
        stackJson.setOwner(DUMMY_HASH);
View Full Code Here

TOP

Related Classes of com.sequenceiq.cloudbreak.controller.json.ClusterResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.