Search in sources :

Example 51 with GetSchema

use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.

the class CommandRequestTest method equalCommandsShouldBeMerged.

@Test
public void equalCommandsShouldBeMerged() {
    assumeThat(new GetSchema(), is(equalTo(new GetSchema())));
    CommandRequest firstCommand = new CommandRequest(new GetSchema(), new NullCallback());
    List<CommandRequest> pending = Collections.singletonList(firstCommand);
    CommandRequest secondRequest = new CommandRequest(new GetSchema(), new NullCallback());
    boolean merged = secondRequest.mergeSuccessfulInto(pending);
    assertThat("merged", merged, is(true));
    assertThat(firstCommand.getCallbacks(), hasItem(first(secondRequest.getCallbacks())));
}
Also used : NullCallback(com.bedatadriven.rebar.async.NullCallback) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 52 with GetSchema

use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.

the class DbListPresenterTest method loaderPopulatesStore.

@Test
public void loaderPopulatesStore() {
    ignoreView();
    expectDispatch(new GetSchema(), schema);
    replay(dispatcher);
    createPresenter();
    ListStore<UserDatabaseDTO> store = presenter.getStore();
    assertThat("store.getCount()", store.getCount(), is(equalTo(3)));
    verify(dispatcher);
}
Also used : UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 53 with GetSchema

use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.

the class SiteAdminTreeLoaderTest method load.

@Test
public void load() {
    DispatcherStub dispatcher = new DispatcherStub();
    dispatcher.setResult(new GetSchema(), DTOs.PEAR.SCHEMA);
    dispatcher.setResult(new GetAdminEntities(1), DTOs.PROVINCES);
    SiteAdminTreeLoader loader = new SiteAdminTreeLoader(dispatcher, new AdminGroupingModel(1));
    new TreeStore<ModelData>(loader);
    loader.load();
}
Also used : AdminGroupingModel(org.activityinfo.client.page.entry.grouping.AdminGroupingModel) TreeStore(com.extjs.gxt.ui.client.store.TreeStore) DispatcherStub(org.activityinfo.client.dispatch.DispatcherStub) GetAdminEntities(org.activityinfo.shared.command.GetAdminEntities) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 54 with GetSchema

use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.

the class CreateDatabaseTest method createWithSpecificCountry.

@Test
@OnDataSet("/dbunit/multicountry.db.xml")
public void createWithSpecificCountry() throws CommandException {
    UserDatabaseDTO db = new UserDatabaseDTO();
    db.setName("Warchild Haiti");
    db.setFullName("Warchild Haiti");
    setUser(1);
    CreateEntity cmd = new CreateEntity(db);
    cmd.getProperties().put("countryId", 2);
    CreateResult cr = execute(cmd);
    SchemaDTO schema = execute(new GetSchema());
    UserDatabaseDTO newdb = schema.getDatabaseById(cr.getNewId());
    assertNotNull(newdb);
    assertThat(newdb.getCountry(), is(notNullValue()));
    assertThat(newdb.getCountry().getName(), is(equalTo("Haiti")));
}
Also used : CreateEntity(org.activityinfo.shared.command.CreateEntity) CreateResult(org.activityinfo.shared.command.result.CreateResult) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 55 with GetSchema

use of org.activityinfo.shared.command.GetSchema in project activityinfo by bedatadriven.

the class DeleteTest method testDeleteAttribute.

@Test
public void testDeleteAttribute() throws CommandException {
    SchemaDTO schema = execute(new GetSchema());
    execute(new Delete(schema.getActivityById(1).getAttributeById(1)));
    schema = execute(new GetSchema());
    Assert.assertNull(schema.getActivityById(1).getAttributeById(1));
}
Also used : Delete(org.activityinfo.shared.command.Delete) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Aggregations

GetSchema (org.activityinfo.shared.command.GetSchema)65 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)56 Test (org.junit.Test)42 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)15 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)10 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)9 CreateResult (org.activityinfo.shared.command.result.CreateResult)8 CreateEntity (org.activityinfo.shared.command.CreateEntity)5 Filter (org.activityinfo.shared.command.Filter)5 HashMap (java.util.HashMap)4 MaskingAsyncMonitor (org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor)4 Delete (org.activityinfo.shared.command.Delete)4 UpdateEntity (org.activityinfo.shared.command.UpdateEntity)4 OnDataSet (org.activityinfo.server.database.OnDataSet)3 BatchCommand (org.activityinfo.shared.command.BatchCommand)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 Produces (javax.ws.rs.Produces)2 WebApplicationException (javax.ws.rs.WebApplicationException)2