Search in sources :

Example 61 with SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.

the class ProjectTest method constraintViolation.

@Test(expected = Exception.class)
public void constraintViolation() {
    setUser(1);
    SchemaDTO schema = execute(new GetSchema());
    ProjectDTO project = schema.getProjectById(2);
    project.setName(null);
    execute(RequestChange.update(project, "name"));
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 62 with SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.

the class GetSchemaTest method testDatabaseVisibilityForOwners.

@Test
public void testDatabaseVisibilityForOwners() throws CommandException {
    // owners should be able to see their databases
    // Alex
    setUser(1);
    SchemaDTO schema = execute(new GetSchema());
    assertThat("database count", schema.getDatabases().size(), equalTo(3));
    assertThat("database list is sorted", schema.getDatabases().get(0).getName(), equalTo("Alpha"));
    // PEAR
    assertTrue("ALEX(owner) in PEAR", schema.getDatabaseById(1) != null);
    assertTrue("ALEX can design", schema.getDatabaseById(1).isDesignAllowed());
    assertTrue("Alex can edit all", schema.getDatabaseById(1).isEditAllowed());
    assertTrue("object graph is preserved", schema.getDatabaseById(1).getCountry() == schema.getDatabaseById(2).getCountry());
    assertTrue("object graph is preserved (database-activity)", schema.getDatabaseById(1) == schema.getDatabaseById(1).getActivities().get(0).getDatabase());
    AdminLevelDTO adminLevel = schema.getCountries().get(0).getAdminLevels().get(0);
    assertThat("CountryId is not null", adminLevel.getCountryId(), not(equalTo(0)));
    assertThat("CountryId is not null", adminLevel.getId(), not(equalTo(0)));
    assertTrue("CountryId is not null", schema.getCountries().get(0).getAdminLevels().get(0).getCountryId() != 0);
    assertThat("deleted attribute is not present", schema.getActivityById(1).getAttributeGroups().size(), equalTo(3));
}
Also used : AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 63 with SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.

the class GetSchemaTest method testDatabaseVisibilityForView.

@Test
public void testDatabaseVisibilityForView() throws CommandException {
    // Bavon
    setUser(2);
    SchemaDTO schema = execute(new GetSchema());
    assertThat(schema.getDatabases().size(), equalTo(1));
    assertThat("BAVON in PEAR", schema.getDatabaseById(1), is(not(nullValue())));
    assertThat(schema.getDatabaseById(1).getMyPartnerId(), equalTo(1));
    assertThat(schema.getDatabaseById(1).isEditAllowed(), equalTo(true));
    assertThat(schema.getDatabaseById(1).isEditAllAllowed(), equalTo(false));
}
Also used : SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 64 with SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.

the class GetSchemaTest method testAttributes.

@Test
public void testAttributes() throws CommandException {
    // Alex
    setUser(1);
    SchemaDTO schema = execute(new GetSchema());
    assertTrue("no attributes case", schema.getActivityById(3).getAttributeGroups().size() == 0);
    ActivityDTO nfi = schema.getActivityById(1);
    AttributeDTO[] attributes = nfi.getAttributeGroupById(1).getAttributes().toArray(new AttributeDTO[0]);
    assertTrue("attributes are present", attributes.length == 2);
    AttributeDTO test = nfi.getAttributeById(1);
    assertEquals("property:name", "Catastrophe Naturelle", test.getName());
}
Also used : AttributeDTO(org.activityinfo.shared.dto.AttributeDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 65 with SchemaDTO

use of org.activityinfo.shared.dto.SchemaDTO in project activityinfo by bedatadriven.

the class PartnerTest method testAddNewPartner.

@Test
public void testAddNewPartner() throws Exception {
    PartnerDTO newPartner = new PartnerDTO();
    newPartner.setName("VDE");
    newPartner.setFullName("Vision d'Espoir");
    CreateResult cr = execute(new AddPartner(1, newPartner));
    SchemaDTO schema = execute(new GetSchema());
    PartnerDTO partner = schema.getDatabaseById(1).getPartnerById(cr.getNewId());
    Assert.assertNotNull(partner);
    Assert.assertEquals("VDE", partner.getName());
    Assert.assertEquals("Vision d'Espoir", partner.getFullName());
}
Also used : PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) DuplicateCreateResult(org.activityinfo.shared.command.result.DuplicateCreateResult) AddPartner(org.activityinfo.shared.command.AddPartner) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Aggregations

SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)66 GetSchema (org.activityinfo.shared.command.GetSchema)56 Test (org.junit.Test)41 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)20 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)10 CreateResult (org.activityinfo.shared.command.result.CreateResult)9 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)8 MockEventBus (org.activityinfo.client.MockEventBus)6 HashMap (java.util.HashMap)5 DispatcherStub (org.activityinfo.client.dispatch.DispatcherStub)5 UIConstants (org.activityinfo.client.i18n.UIConstants)5 StateManagerStub (org.activityinfo.client.mock.StateManagerStub)5 OnDataSet (org.activityinfo.server.database.OnDataSet)5 Delete (org.activityinfo.shared.command.Delete)5 Filter (org.activityinfo.shared.command.Filter)5 UpdateEntity (org.activityinfo.shared.command.UpdateEntity)5 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)5 MaskingAsyncMonitor (org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor)4 CreateEntity (org.activityinfo.shared.command.CreateEntity)4 VoidResult (org.activityinfo.shared.command.result.VoidResult)4