Java Code Examples for org.camunda.bpm.engine.identity.Tenant#setName()

The following examples show how to use org.camunda.bpm.engine.identity.Tenant#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IdentityServiceUserOperationLogTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldLogTenantUpdate() {
  // given
  Tenant newTenant = identityService.newTenant(TEST_TENANT_ID);
  identityService.saveTenant(newTenant);
  assertEquals(0, query.count());

  // when
  newTenant.setName("testName");
  identityService.setAuthenticatedUserId("userId");
  identityService.saveTenant(newTenant);
  identityService.clearAuthentication();

  // then
  assertLog(UserOperationLogEntry.OPERATION_TYPE_UPDATE, EntityTypes.TENANT, null, TEST_TENANT_ID);
}
 
Example 2
Source File: IdentityServiceTenantTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void createExistingTenant() {
  Tenant tenant = identityService.newTenant(TENANT_ONE);
  tenant.setName("Tenant");
  identityService.saveTenant(tenant);

  Tenant secondTenant = identityService.newTenant(TENANT_ONE);
  secondTenant.setName("Tenant");
  try {
    identityService.saveTenant(secondTenant);
    fail("BadUserRequestException is expected");
  } catch (Exception ex) {
    if (!(ex instanceof BadUserRequestException)) {
      fail("BadUserRequestException is expected, but another exception was received:  " + ex);
    }
    assertEquals("The tenant already exists", ex.getMessage());
  }
}
 
Example 3
Source File: IdentityServiceTenantTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void updateTenant() {
  // create
  Tenant tenant = identityService.newTenant(TENANT_ONE);
  tenant.setName("Tenant");
  identityService.saveTenant(tenant);

  // update
  tenant = identityService.createTenantQuery().singleResult();
  assertThat(tenant, is(notNullValue()));

  tenant.setName("newName");
  identityService.saveTenant(tenant);

  tenant = identityService.createTenantQuery().singleResult();
  assertEquals("newName", tenant.getName());
}
 
Example 4
Source File: IdentityServiceTenantTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void updateTenantOptimisticLockingException() {
  // create
  Tenant tenant = identityService.newTenant(TENANT_ONE);
  identityService.saveTenant(tenant);

  Tenant tenant1 = identityService.createTenantQuery().singleResult();
  Tenant tenant2 = identityService.createTenantQuery().singleResult();

  // update
  tenant1.setName("name");
  identityService.saveTenant(tenant1);

  thrown.expect(ProcessEngineException.class);

  // fail to update old revision
  tenant2.setName("other name");
  identityService.saveTenant(tenant2);
}
 
Example 5
Source File: IdentityServiceAuthorizationsTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testTenantUpdateAuthorizations() {

    // create tenant
    Tenant tenant = new TenantEntity("tenant");
    identityService.saveTenant(tenant);

    // create global auth
    Authorization basePerms = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL);
    basePerms.setResource(TENANT);
    basePerms.setResourceId(ANY);
    basePerms.addPermission(ALL);
    basePerms.removePermission(UPDATE); // revoke update
    authorizationService.saveAuthorization(basePerms);

    // turn on authorization
    processEngineConfiguration.setAuthorizationEnabled(true);
    identityService.setAuthenticatedUserId(jonny2);

    // fetch user:
    tenant = identityService.createTenantQuery().singleResult();
    tenant.setName("newName");

    try {
      identityService.saveTenant(tenant);

      fail("exception expected");
    } catch (AuthorizationException e) {
      assertEquals(1, e.getMissingAuthorizations().size());
      MissingAuthorization info = e.getMissingAuthorizations().get(0);
      assertEquals(jonny2, e.getUserId());
      assertExceptionInfo(UPDATE.getName(), TENANT.resourceName(), "tenant", info);
    }

    // but I can create a new tenant:
    Tenant newTenant = identityService.newTenant("newTenant");
    identityService.saveTenant(newTenant);
  }
 
Example 6
Source File: IdentityServiceTenantTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void createTenant() {
  Tenant tenant = identityService.newTenant(TENANT_ONE);
  tenant.setName("Tenant");
  identityService.saveTenant(tenant);

  tenant = identityService.createTenantQuery().singleResult();
  assertThat(tenant, is(notNullValue()));
  assertThat(tenant.getId(), is(TENANT_ONE));
  assertThat(tenant.getName(), is("Tenant"));
}
 
Example 7
Source File: TenantQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected Tenant createTenant(String id, String name) {
  Tenant tenant = engineRule.getIdentityService().newTenant(id);
  tenant.setName(name);
  identityService.saveTenant(tenant);

  return tenant;
}
 
Example 8
Source File: TenantDto.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void update(Tenant tenant) {
  tenant.setId(id);
  tenant.setName(name);
}