use of com.icthh.xm.commons.gen.model.Tenant in project xm-ms-entity by xm-online.
the class TenantResourceIntTest method createDeleteTenant.
@Test
@Transactional
public void createDeleteTenant() throws Exception {
Connection connection = dataSource.getConnection();
// int countXm = countTables(connection, TENANT_SUPER);
Tenant tenant = new Tenant();
tenant.setTenantKey(TENANT_NEW);
// Create tenant
mockMvc.perform(post(API_ENDPOINT).contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(tenant))).andExpect(status().isOk());
// Check schema created
ResultSet schemas = connection.getMetaData().getSchemas();
boolean found = false;
while (schemas.next()) {
if (TENANT_NEW.equals(schemas.getString(1))) {
found = true;
}
}
assertEquals(true, found);
// Check tables created
assertTrue(countTables(connection, TENANT_NEW) > 1);
// delete tenant
mockMvc.perform(delete(API_ENDPOINT + "{tenantKey}", TENANT_NEW).accept(TestUtil.APPLICATION_JSON_UTF8)).andExpect(status().isOk());
// Check schema deleted
ResultSet schemasNew = connection.getMetaData().getSchemas();
boolean foundDeleted = false;
while (!foundDeleted && schemasNew.next()) {
if (TENANT_NEW.equals(schemasNew.getString(1))) {
foundDeleted = true;
}
}
assertEquals(false, foundDeleted);
}
use of com.icthh.xm.commons.gen.model.Tenant in project xm-ms-entity by xm-online.
the class XmTenantLifecycleService method manageClient.
private void manageClient(String serviceName, XmEntity xmEntity, String nextStateKey) {
if (StringUtils.isNotBlank(serviceName)) {
TenantClient client = getClient(serviceName);
String tenantName = xmEntity.getName();
String currStateKey = xmEntity.getStateKey();
if (ACTIVE.name().equals(nextStateKey) && CURRENT_STATE_CREATE_ALLOWED.contains(currStateKey)) {
client.addTenant(new Tenant().tenantKey(tenantName).name(tenantName));
} else if (ACTIVE.name().equals(nextStateKey) && SUSPENDED.name().equals(currStateKey)) {
client.manageTenant(tenantName, ACTIVE.name());
} else if (SUSPENDED.name().equals(nextStateKey) && ACTIVE.name().equals(currStateKey)) {
client.manageTenant(tenantName, SUSPENDED.name());
} else if (DELETED.name().equals(nextStateKey)) {
client.deleteTenant(tenantName);
}
}
}
Aggregations