Skip to content
Permalink
Browse files
Fixed TestTenants.
  • Loading branch information
mifosio-04-04-2018 committed Jun 8, 2017
1 parent d367911 commit c0324a04cab3a6714988d79189a63b4b0960598f
Showing 3 changed files with 15 additions and 11 deletions.
@@ -22,26 +22,24 @@
import io.mifos.provisioner.api.v1.domain.Tenant;

class Fixture {
static final String TENANT_NAME = "Comp Test";

static Tenant getCompTestTenant() {
final Tenant compTestTenant = new Tenant();
compTestTenant.setIdentifier(TestEnvironment.getRandomTenantName());
compTestTenant.setName(TENANT_NAME);
compTestTenant.setName("Comp Test");
compTestTenant.setDescription("Component Test Tenant");

final CassandraConnectionInfo cassandraConnectionInfo = new CassandraConnectionInfo();
compTestTenant.setCassandraConnectionInfo(cassandraConnectionInfo);
cassandraConnectionInfo.setClusterName("Test Cluster");
cassandraConnectionInfo.setContactPoints("127.0.0.1:9142");
cassandraConnectionInfo.setKeyspace("comp_test");
cassandraConnectionInfo.setKeyspace(compTestTenant.getIdentifier());
cassandraConnectionInfo.setReplicas("3");
cassandraConnectionInfo.setReplicationType("Simple");

final DatabaseConnectionInfo databaseConnectionInfo = new DatabaseConnectionInfo();
compTestTenant.setDatabaseConnectionInfo(databaseConnectionInfo);
databaseConnectionInfo.setDriverClass("org.mariadb.jdbc.Driver");
databaseConnectionInfo.setDatabaseName("comp_test");
databaseConnectionInfo.setDatabaseName(compTestTenant.getIdentifier());
databaseConnectionInfo.setHost("localhost");
databaseConnectionInfo.setPort("3306");
databaseConnectionInfo.setUser("root");
@@ -29,6 +29,8 @@
import org.junit.Before;
import org.junit.Test;

import java.util.List;

public class TestTenants extends AbstractServiceTest {

public TestTenants() {
@@ -47,7 +49,7 @@ public void before()

@After
public void after() throws InterruptedException {
provisioner.deleteTenant(Fixture.getCompTestTenant().getIdentifier());
//provisioner.deleteTenant(Fixture.getCompTestTenant().getIdentifier());
autoSeshat.close();
}

@@ -68,8 +70,9 @@ public void shouldCreateTenant() throws Exception {

@Test(expected = DuplicateIdentifierException.class)
public void shouldFailCreateDuplicate() {
provisioner.createTenant(Fixture.getCompTestTenant());
provisioner.createTenant(Fixture.getCompTestTenant());
final Tenant tenant = Fixture.getCompTestTenant();
provisioner.createTenant(tenant);
provisioner.createTenant(tenant);
}

@Test
@@ -88,7 +91,10 @@ public void shouldFailFindUnknown() {

@Test
public void shouldFetchAll() {
provisioner.createTenant(Fixture.getCompTestTenant());
Assert.assertFalse(provisioner.getTenants().isEmpty());
final Tenant tenant = Fixture.getCompTestTenant();
provisioner.createTenant(tenant);
final List<Tenant> tenants = provisioner.getTenants();
Assert.assertFalse(tenants.isEmpty());
Assert.assertTrue(tenants.contains(tenant));
}
}
@@ -110,7 +110,7 @@ public void create(final @Nonnull TenantEntity tenant) {
tenant.getReplicas()));
}
catch (final AlreadyExistsException e) {
throw ServiceException.conflict("Tenant {0} already exists!", tenant.getIdentifier());
throw ServiceException.badRequest("Tenant keyspace {0} already exists!", tenant.getKeyspaceName());
}

final String createCommandSourceTable =

0 comments on commit c0324a0

Please sign in to comment.