Search in sources :

Example 6 with Topology

use of com.sequenceiq.cloudbreak.domain.Topology in project cloudbreak by hortonworks.

the class CredentialServiceTest method init.

@Before
public void init() throws Exception {
    doNothing().when(authorizationService).hasWritePermission(any());
    doNothing().when(notificationSender).send(any());
    when(credentialAdapter.init(any(Credential.class))).then(invocation -> invocation.getArgumentAt(0, Credential.class));
    credentialToModify = new Credential();
    credentialToModify.setId(1L);
    credentialToModify.setCloudPlatform(PLATFORM);
    originalTopology = new Topology();
    credentialToModify.setTopology(originalTopology);
    originalDescription = "orig-desc";
    credentialToModify.setDescription(originalDescription);
    originalAttributes = new Json("test");
    credentialToModify.setAttributes(originalAttributes);
    when(credentialRepository.findByNameInUser(anyString(), anyString())).thenReturn(credentialToModify);
    when(credentialRepository.findOneByName(anyString(), anyString())).thenReturn(credentialToModify);
    when(credentialRepository.save(any(Credential.class))).then(invocation -> invocation.getArgumentAt(0, Credential.class));
    user = new IdentityUser("asef", "asdf", "asdf", null, "ASdf", "asdf", new Date());
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) Credential(com.sequenceiq.cloudbreak.domain.Credential) Topology(com.sequenceiq.cloudbreak.domain.Topology) Json(com.sequenceiq.cloudbreak.domain.json.Json) Date(java.util.Date) Before(org.junit.Before)

Example 7 with Topology

use of com.sequenceiq.cloudbreak.domain.Topology in project cloudbreak by hortonworks.

the class TopologyRequestToTopologyConverter method convert.

@Override
public Topology convert(TopologyRequest source) {
    Topology result = new Topology();
    result.setName(source.getName());
    result.setDescription(source.getDescription());
    result.setCloudPlatform(source.getCloudPlatform());
    result.setRecords(convertNodes(source.getNodes()));
    return result;
}
Also used : Topology(com.sequenceiq.cloudbreak.domain.Topology)

Example 8 with Topology

use of com.sequenceiq.cloudbreak.domain.Topology in project cloudbreak by hortonworks.

the class TopologyService method create.

@Transactional(TxType.NEVER)
public Topology create(IdentityUser user, Topology topology) {
    LOGGER.debug("Creating topology: [User: '{}', Account: '{}']", user.getUsername(), user.getAccount());
    Topology savedTopology;
    topology.setOwner(user.getUserId());
    topology.setAccount(user.getAccount());
    try {
        savedTopology = topologyRepository.save(topology);
    } catch (DataIntegrityViolationException ex) {
        String msg = String.format("Error with resource [%s], error: [%s]", APIResourceType.TOPOLOGY, getProperSqlErrorMessage(ex));
        throw new BadRequestException(msg);
    }
    return savedTopology;
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) Topology(com.sequenceiq.cloudbreak.domain.Topology) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) Transactional(javax.transaction.Transactional)

Example 9 with Topology

use of com.sequenceiq.cloudbreak.domain.Topology in project cloudbreak by hortonworks.

the class TopologyService method get.

public Topology get(Long id) {
    Topology topology = getById(id);
    authorizationService.hasReadPermission(topology);
    return topology;
}
Also used : Topology(com.sequenceiq.cloudbreak.domain.Topology)

Aggregations

Topology (com.sequenceiq.cloudbreak.domain.Topology)9 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)3 Credential (com.sequenceiq.cloudbreak.domain.Credential)2 Json (com.sequenceiq.cloudbreak.domain.json.Json)2 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)1 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)1 TopologyRecord (com.sequenceiq.cloudbreak.domain.TopologyRecord)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Transactional (javax.transaction.Transactional)1 Before (org.junit.Before)1 Test (org.junit.Test)1 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)1