fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From my...@apache.org
Subject [fineract-cn-provisioner] 36/50: Fixed TestTenants.
Date Mon, 22 Jan 2018 15:16:34 GMT
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-provisioner.git

commit c0324a04cab3a6714988d79189a63b4b0960598f
Author: myrle-krantz <mkrantz@mifos.org>
AuthorDate: Thu Jun 8 20:32:15 2017 +0200

    Fixed TestTenants.
---
 .../main/java/io/mifos/provisioner/tenant/Fixture.java   |  8 +++-----
 .../java/io/mifos/provisioner/tenant/TestTenants.java    | 16 +++++++++++-----
 .../internal/repository/TenantCassandraRepository.java   |  2 +-
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/component-test/src/main/java/io/mifos/provisioner/tenant/Fixture.java b/component-test/src/main/java/io/mifos/provisioner/tenant/Fixture.java
index eb457f9..6e6b5ae 100644
--- a/component-test/src/main/java/io/mifos/provisioner/tenant/Fixture.java
+++ b/component-test/src/main/java/io/mifos/provisioner/tenant/Fixture.java
@@ -22,26 +22,24 @@ import io.mifos.provisioner.api.v1.domain.DatabaseConnectionInfo;
 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");
diff --git a/component-test/src/main/java/io/mifos/provisioner/tenant/TestTenants.java b/component-test/src/main/java/io/mifos/provisioner/tenant/TestTenants.java
index 2fade74..6c436ac 100644
--- a/component-test/src/main/java/io/mifos/provisioner/tenant/TestTenants.java
+++ b/component-test/src/main/java/io/mifos/provisioner/tenant/TestTenants.java
@@ -29,6 +29,8 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import java.util.List;
+
 public class TestTenants extends AbstractServiceTest {
 
   public TestTenants() {
@@ -47,7 +49,7 @@ public class TestTenants extends AbstractServiceTest {
 
   @After
   public void after() throws InterruptedException {
-    provisioner.deleteTenant(Fixture.getCompTestTenant().getIdentifier());
+    //provisioner.deleteTenant(Fixture.getCompTestTenant().getIdentifier());
     autoSeshat.close();
   }
 
@@ -68,8 +70,9 @@ public class TestTenants extends AbstractServiceTest {
 
   @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 class TestTenants extends AbstractServiceTest {
 
   @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));
   }
 }
diff --git a/service/src/main/java/io/mifos/provisioner/internal/repository/TenantCassandraRepository.java
b/service/src/main/java/io/mifos/provisioner/internal/repository/TenantCassandraRepository.java
index 7294702..4384cd3 100644
--- a/service/src/main/java/io/mifos/provisioner/internal/repository/TenantCassandraRepository.java
+++ b/service/src/main/java/io/mifos/provisioner/internal/repository/TenantCassandraRepository.java
@@ -110,7 +110,7 @@ public class TenantCassandraRepository {
                       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 =

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

Mime
View raw message