use of org.openstack4j.model.identity.v3.Domain in project camel by apache.
the class DomainProducer method doCreate.
private void doCreate(Exchange exchange) {
final Domain in = messageToDomain(exchange.getIn());
final Domain out = osV3Client.identity().domains().create(in);
exchange.getIn().setBody(out);
}
use of org.openstack4j.model.identity.v3.Domain in project camel by apache.
the class DomainProducer method messageToDomain.
private Domain messageToDomain(Message message) {
Domain domain = message.getBody(Domain.class);
if (domain == null) {
Map headers = message.getHeaders();
DomainBuilder builder = Builders.domain();
ObjectHelper.notEmpty(message.getHeader(OpenstackConstants.NAME, String.class), "Name");
builder.name(message.getHeader(OpenstackConstants.NAME, String.class));
if (headers.containsKey(KeystoneConstants.DESCRIPTION)) {
builder.description(message.getHeader(KeystoneConstants.DESCRIPTION, String.class));
}
domain = builder.build();
}
return domain;
}
use of org.openstack4j.model.identity.v3.Domain in project camel by apache.
the class DomainProducerTest method setUp.
@Before
public void setUp() {
producer = new DomainProducer(endpoint, client);
when(domainService.create(any(Domain.class))).thenReturn(testOSdomain);
when(domainService.get(anyString())).thenReturn(testOSdomain);
List<Domain> getAllList = new ArrayList<>();
getAllList.add(testOSdomain);
getAllList.add(testOSdomain);
doReturn(getAllList).when(domainService).list();
dummyDomain = createDomain();
when(testOSdomain.getName()).thenReturn(dummyDomain.getName());
when(testOSdomain.getDescription()).thenReturn(dummyDomain.getDescription());
}
use of org.openstack4j.model.identity.v3.Domain in project openstack4j by ContainX.
the class KeystoneDomainServiceTests method crud_domain_test.
// ------------ Domain Tests ------------
// Tests here just address the missing update() spec feature.
// Find more tests in the respective KeystoneXService.spec in
// core-integration-test module
public void crud_domain_test() throws Exception {
// create a new domain
Domain domain = Builders.domain().name(DOMAIN_NAME).description(DOMAIN_DESCRIPTION).enabled(true).build();
respondWith(JSON_DOMAINS_CREATE);
Domain newDomain = osv3().identity().domains().create(domain);
assertEquals(newDomain.getName(), DOMAIN_NAME);
assertEquals(newDomain.getDescription(), DOMAIN_DESCRIPTION);
String DOMAIN_ID = newDomain.getId();
// update an existing domain
respondWith(JSON_DOMAINS_UPDATE);
Domain updatedDomain = osv3().identity().domains().update(Builders.domain().id(DOMAIN_ID).description(DOMAIN_DESCRIPTION_UPDATED).enabled(true).build());
assertEquals(updatedDomain.getId(), DOMAIN_ID);
assertEquals(updatedDomain.getName(), DOMAIN_NAME);
assertEquals(updatedDomain.getDescription(), DOMAIN_DESCRIPTION_UPDATED);
}
use of org.openstack4j.model.identity.v3.Domain in project openstack4j by ContainX.
the class KeystoneUserServiceTests method getUser_byName_byDomainId_NotExist_Test.
/**
* returns null for an non-existing user when the user specified by name and domain.
*
* @throws Exception
*/
public void getUser_byName_byDomainId_NotExist_Test() throws Exception {
respondWith(JSON_USER_GET_BYNAME_BYDOMAINID_NOT_EXIST);
User user = osv3().identity().users().getByName(USER_NAME, USER_DOMAIN_ID);
assertNull(user);
}
Aggregations