Search in sources :

Example 16 with GetSchema

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

the class SchemaCacheTest method testSchemaCache.

@Test
public void testSchemaCache() {
    CacheManager proxyMgr = new CacheManager(new MockEventBus());
    new SchemaCache(proxyMgr);
    SchemaDTO schema = DTOs.pear();
    proxyMgr.notifyListenersOfSuccess(new GetSchema(), schema);
    CacheResult<SchemaDTO> proxyResult = proxyMgr.execute(new GetSchema());
    Assert.assertTrue("could execute locally", proxyResult.isCouldExecute());
    Assert.assertEquals("PEAR", proxyResult.getResult().getDatabaseById(1).getName());
}
Also used : MockEventBus(org.activityinfo.client.MockEventBus) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 17 with GetSchema

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

the class MockRemoteCommandService method execute.

@Override
public void execute(String authToken, List<Command> cmds, AsyncCallback<List<CommandResult>> callback) {
    List<CommandResult> results = new ArrayList<CommandResult>();
    for (Command cmd : cmds) {
        Integer count = commandCounts.get(cmd.getClass());
        commandCounts.put(cmd.getClass(), count == null ? 1 : count + 1);
        if (schema != null && cmd instanceof GetSchema) {
            results.add(schema);
        } else {
            results.add(mockExecute(cmd));
        }
    }
    callback.onSuccess(results);
}
Also used : Command(org.activityinfo.shared.command.Command) ArrayList(java.util.ArrayList) GetSchema(org.activityinfo.shared.command.GetSchema) CommandResult(org.activityinfo.shared.command.result.CommandResult)

Example 18 with GetSchema

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

the class DbListPresenterTest method commandShouldBePreparedProperly.

@Test
public void commandShouldBePreparedProperly() {
    Capture<CreateEntity> cmd = new Capture<CreateEntity>();
    expectDispatch(new GetSchema(), schema);
    captureDispatch(cmd);
    replay(dispatcher);
    UserDatabaseDTO newDb = new UserDatabaseDTO();
    newDb.setCountry(new CountryDTO(31, "Haiti"));
    newDb.setName("My Db");
    createPresenter();
    presenter.save(newDb, niceFormDialogMock());
    assertTrue("command was dispatched", cmd.hasCaptured());
    assertThat((Integer) cmd.getValue().getProperties().get("countryId"), is(equalTo(31)));
}
Also used : CreateEntity(org.activityinfo.shared.command.CreateEntity) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) CountryDTO(org.activityinfo.shared.dto.CountryDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Capture(org.easymock.Capture) Test(org.junit.Test)

Example 19 with GetSchema

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

the class ActivityTest method updatePublished.

@Test
public void updatePublished() throws Throwable {
    /* Update Sort Order */
    Map<String, Object> changes = new HashMap<String, Object>();
    changes.put("published", Published.ALL_ARE_PUBLISHED.getIndex());
    execute(new UpdateEntity("Activity", 1, changes));
    /* Confirm the order is changed */
    SchemaDTO schema = execute(new GetSchema());
    Assert.assertEquals(Published.ALL_ARE_PUBLISHED.getIndex(), schema.getActivityById(1).getPublished());
}
Also used : UpdateEntity(org.activityinfo.shared.command.UpdateEntity) HashMap(java.util.HashMap) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Example 20 with GetSchema

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

the class ActivityTest method updateSortOrderTest.

@Test
public void updateSortOrderTest() throws Throwable {
    /* Update Sort Order */
    Map<String, Object> changes1 = new HashMap<String, Object>();
    changes1.put("sortOrder", 2);
    Map<String, Object> changes2 = new HashMap<String, Object>();
    changes2.put("sortOrder", 1);
    execute(new BatchCommand(new UpdateEntity("Activity", 1, changes1), new UpdateEntity("Activity", 2, changes2)));
    /* Confirm the order is changed */
    SchemaDTO schema = execute(new GetSchema());
    Assert.assertEquals(2, schema.getDatabaseById(1).getActivities().get(0).getId());
    Assert.assertEquals(1, schema.getDatabaseById(1).getActivities().get(1).getId());
}
Also used : UpdateEntity(org.activityinfo.shared.command.UpdateEntity) HashMap(java.util.HashMap) BatchCommand(org.activityinfo.shared.command.BatchCommand) 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