Package com.sequenceiq.cloudbreak.controller.json

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


    @Autowired
    private MetaDataConverter metaDataConverter;

    @Override
    public StackJson convert(Stack entity) {
        StackJson stackJson = new StackJson();
        stackJson.setTemplateId(entity.getTemplate().getId());
        stackJson.setNodeCount(entity.getNodeCount());
        stackJson.setName(entity.getName());
        stackJson.setOwner(entity.getOwner());
        stackJson.setAccount(entity.getAccount());
        stackJson.setPublicInAccount(entity.isPublicInAccount());
        stackJson.setId(entity.getId());
        stackJson.setCloudPlatform(entity.getTemplate().cloudPlatform());
        stackJson.setCredentialId(entity.getCredential().getId());
        stackJson.setStatus(entity.getStatus());
        stackJson.setStatusReason(entity.getStatusReason());
        stackJson.setAmbariServerIp(entity.getAmbariIp());
        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


        }
        return stackJson;
    }

    public StackJson convert(Stack entity, StackDescription description) {
        StackJson stackJson = new StackJson();
        stackJson.setTemplateId(entity.getTemplate().getId());
        stackJson.setNodeCount(entity.getNodeCount());
        stackJson.setId(entity.getId());
        stackJson.setName(entity.getName());
        stackJson.setOwner(entity.getOwner());
        stackJson.setAccount(entity.getAccount());
        stackJson.setPublicInAccount(entity.isPublicInAccount());
        stackJson.setCredentialId(entity.getCredential().getId());
        stackJson.setCloudPlatform(entity.getTemplate().cloudPlatform());
        stackJson.setDescription(description);
        stackJson.setStatus(entity.getStatus());
        stackJson.setHash(entity.getHash());
        stackJson.setStatusReason(entity.getStatusReason());
        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

    @RequestMapping(value = "stacks/{id}", method = RequestMethod.GET)
    @ResponseBody
    public ResponseEntity<StackJson> getStack(@PathVariable Long id) {
        Stack stack = stackService.get(id);
        StackDescription stackDescription = stackService.getStackDescription(stack);
        StackJson stackJson = stackConverter.convert(stack, stackDescription);
        return new ResponseEntity<>(stackJson, HttpStatus.OK);
    }
View Full Code Here

    public void testConvertStackEntityToJsonWithStackDescription() {
        // GIVEN
        given(metaDataConverter.convertAllJsonToEntity(anySetOf(InstanceMetaDataJson.class)))
                .willReturn(new HashSet<InstanceMetaData>());
        // WHEN
        StackJson result = underTest.convert(stack, stackDescription);
        // THEN
        assertEquals(result.getAmbariServerIp(), stack.getAmbariIp());
        assertEquals(result.getId(), stack.getId());
        assertEquals(result.getCloudPlatform(), CloudPlatform.AWS);
        assertNotNull(result.getMetadata());
        verify(clusterConverter, times(1)).convert(any(Cluster.class), anyString());
    }
View Full Code Here

        // GIVEN
        stack.setCluster(null);
        given(metaDataConverter.convertAllJsonToEntity(anySetOf(InstanceMetaDataJson.class)))
                .willReturn(new HashSet<InstanceMetaData>());
        // WHEN
        StackJson result = underTest.convert(stack, stackDescription);
        // THEN
        assertEquals(result.getAmbariServerIp(), stack.getAmbariIp());
        assertEquals(result.getId(), stack.getId());
        assertEquals(result.getCloudPlatform(), CloudPlatform.AWS);
        assertNotNull(result.getMetadata());
        verify(clusterConverter, times(0)).convert(any(Cluster.class), anyString());
    }
View Full Code Here

        stack.setOwner(DUMMY_NAME);
        return stack;
    }

    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);
        stackJson.setMetadata(new HashSet<InstanceMetaDataJson>());
        stackJson.setName(DUMMY_NAME);
        stackJson.setNodeCount(NODE_COUNT);
        stackJson.setStatus(Status.AVAILABLE);
        stackJson.setTemplateId(DUMMY_ID);
        return stackJson;
    }
View Full Code Here

    public void testConvertStackEntityToJson() {
        // GIVEN
        given(metaDataConverter.convertAllJsonToEntity(anySetOf(InstanceMetaDataJson.class)))
                .willReturn(new HashSet<InstanceMetaData>());
        // WHEN
        StackJson result = underTest.convert(stack);
        // THEN
        assertEquals(result.getAmbariServerIp(), stack.getAmbariIp());
        assertEquals(result.getId(), stack.getId());
        assertEquals(result.getCloudPlatform(), CloudPlatform.AWS);
        assertNotNull(result.getMetadata());
        assertEquals(result.getAccount(), DUMMY_NAME);
        assertEquals(result.getOwner(), DUMMY_NAME);
        assertTrue(result.isPublicInAccount());
        verify(clusterConverter, times(1)).convert(any(Cluster.class), anyString());
    }
View Full Code Here

        // GIVEN
        stack.setCluster(null);
        given(metaDataConverter.convertAllJsonToEntity(anySetOf(InstanceMetaDataJson.class)))
                .willReturn(new HashSet<InstanceMetaData>());
        // WHEN
        StackJson result = underTest.convert(stack);
        // THEN
        assertEquals(result.getAmbariServerIp(), stack.getAmbariIp());
        assertEquals(result.getId(), stack.getId());
        assertEquals(result.getCloudPlatform(), CloudPlatform.AWS);
        assertNotNull(result.getMetadata());
        verify(clusterConverter, times(0)).convert(any(Cluster.class), anyString());
    }
View Full Code Here

TOP

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

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.