use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class HalTenantResolver method resolveNotCachedLinks.
@Override
protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) {
IdentityService identityService = processEngine.getIdentityService();
List<Tenant> tenants = identityService.createTenantQuery().tenantIdIn(linkedIds).list();
List<HalResource<?>> resolvedTenants = new ArrayList<HalResource<?>>();
for (Tenant tenant : tenants) {
resolvedTenants.add(HalTenant.fromTenant(tenant));
}
return resolvedTenants;
}
use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class TenantRestServiceInteractionTest method saveTenantThrowsAuthorizationException.
@Test
public void saveTenantThrowsAuthorizationException() {
Tenant newTenant = MockProvider.createMockTenant();
when(identityServiceMock.newTenant(MockProvider.EXAMPLE_TENANT_ID)).thenReturn(newTenant);
String message = "exception expected";
doThrow(new AuthorizationException(message)).when(identityServiceMock).saveTenant(newTenant);
given().body(TenantDto.fromTenant(newTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().post(TENANT_CREATE_URL);
}
use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class TenantRestServiceInteractionTest method updateNonExistingTenant.
@Test
public void updateNonExistingTenant() {
Tenant updatedTenant = MockProvider.createMockTenant();
when(updatedTenant.getName()).thenReturn("updatedName");
when(mockQuery.singleResult()).thenReturn(null);
given().pathParam("id", "aNonExistingTenant").body(TenantDto.fromTenant(updatedTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Tenant with id aNonExistingTenant does not exist")).when().put(TENANT_URL);
verify(identityServiceMock, never()).saveTenant(any(Tenant.class));
}
use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class TenantRestServiceInteractionTest method failToUpdateTenantForReadOnlyService.
@Test
public void failToUpdateTenantForReadOnlyService() {
Tenant updatedTenant = MockProvider.createMockTenant();
when(identityServiceMock.isReadOnly()).thenReturn(true);
given().pathParam("id", MockProvider.EXAMPLE_TENANT_ID).body(TenantDto.fromTenant(updatedTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Identity service implementation is read-only.")).when().put(TENANT_URL);
verify(identityServiceMock, never()).saveTenant(mockTenant);
}
use of org.camunda.bpm.engine.identity.Tenant in project camunda-bpm-platform by camunda.
the class TenantRestServiceInteractionTest method updateTenantThrowsAuthorizationException.
@Test
public void updateTenantThrowsAuthorizationException() {
Tenant updatedTenant = MockProvider.createMockTenant();
when(updatedTenant.getName()).thenReturn("updatedName");
String message = "exception expected";
doThrow(new AuthorizationException(message)).when(identityServiceMock).saveTenant(any(Tenant.class));
given().pathParam("id", MockProvider.EXAMPLE_TENANT_ID).body(TenantDto.fromTenant(updatedTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().put(TENANT_URL);
}
Aggregations