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());
}
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;
}
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;
}
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;
}
Aggregations