Пример #1
0
  @Test
  public void testListTenants() throws Exception {

    // Get the expected list of Tenant objects
    DtoApplication app = topology.getApplication();
    List<Tenant> expected = getExpectedTenants(app.getUri(), 0, 9);

    // Get the actual Tenant objects
    Tenant[] actualRaw =
        dtoResource.getAndVerifyOk(
            app.getTenants(), VendorMediaType.APPLICATION_TENANT_COLLECTION_JSON, Tenant[].class);
    // Fill in because the URI won't get deserialized
    for (Tenant t : actualRaw) {
      t.setBaseUri(topology.getApplication().getUri());
    }
    // Compare the actual and expected
    assertThat(expected, containsInAnyOrder(actualRaw));

    // Test that the URI for 'tenant' is correct in each item
    for (Tenant t : actualRaw) {

      // Construct the expected object
      Tenant expectedTenant = getExpectedTenant(app.getUri(), t.id);

      // Get the actual object
      Tenant actualTenant =
          dtoResource.getAndVerifyOk(
              t.getUri(), VendorMediaType.APPLICATION_TENANT_JSON, Tenant.class);

      // Compare
      assertThat(actualTenant, equalTo(expectedTenant));
    }
  }
Пример #2
0
 @Test
 public void testDtoGeneratesUris() throws Exception {
   String id = "sometenant";
   Tenant t = new Tenant(topology.getApplication().getUri(), id, id + "-name");
   assertEquals(
       t.getUri().toString(),
       topology.getApplication().getUri() + ResourceUris.TENANTS + "/" + id);
 }