Search in sources :

Example 26 with GetSchema

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

the class PartnerTest method testAddPartner.

@Test
public void testAddPartner() {
    PartnerDTO newPartner = new PartnerDTO();
    newPartner.setName("Solidarites");
    CreateResult cr = execute(new UpdatePartner(PEAR_PLUS_DB_ID, newPartner));
    assertThat(cr.getNewId(), not(equalTo(SOL_ID)));
    SchemaDTO schema = execute(new GetSchema());
    PartnerDTO partner = schema.getDatabaseById(PEAR_PLUS_DB_ID).getPartnerById(cr.getNewId());
    Assert.assertNotNull(partner);
    Assert.assertEquals(newPartner.getName(), partner.getName());
}
Also used : PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) DuplicateCreateResult(org.activityinfo.legacy.shared.command.result.DuplicateCreateResult) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) UpdatePartner(org.activityinfo.legacy.shared.command.UpdatePartner) Test(org.junit.Test)

Example 27 with GetSchema

use of org.activityinfo.legacy.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.legacy.shared.model.UserDatabaseDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema) Test(org.junit.Test)

Example 28 with GetSchema

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

the class SchemaImporterV2Test method doImport.

private UserDatabaseDTO doImport(String resourceName) throws IOException {
    Map<String, Object> dbProps = Maps.newHashMap();
    dbProps.put("name", "Syria");
    dbProps.put("countryId", 1);
    int databaseId = execute(new CreateEntity("UserDatabase", dbProps)).getNewId();
    SchemaDTO schema = execute(new GetSchema());
    UserDatabaseDTO db = schema.getDatabaseById(databaseId);
    if (db == null) {
        throw new AssertionError("database not created");
    }
    SchemaImporterV2 importer = new SchemaImporterV2(getDispatcher(), db, warningTemplates());
    importer.setProgressListener(new SchemaImporterV2.ProgressListener() {

        @Override
        public void submittingBatch(int batchNumber, int batchCount) {
            System.out.println("Submitting batch " + batchNumber + " of " + batchCount);
        }
    });
    boolean success = importer.parseColumns(source(resourceName));
    if (success) {
        importer.processRows();
    }
    for (SafeHtml warning : importer.getWarnings()) {
        System.err.println(warning);
    }
    if (!success) {
        throw new AssertionError("there were fatal errors");
    }
    importer.persist(new AsyncCallback<Void>() {

        @Override
        public void onSuccess(Void result) {
            System.out.println("Success");
        }

        @Override
        public void onFailure(Throwable caught) {
            throw new AssertionError(caught);
        }
    });
    return execute(new GetSchema()).getDatabaseById(databaseId);
}
Also used : CreateEntity(org.activityinfo.legacy.shared.command.CreateEntity) UserDatabaseDTO(org.activityinfo.legacy.shared.model.UserDatabaseDTO) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SchemaDTO(org.activityinfo.legacy.shared.model.SchemaDTO) GetSchema(org.activityinfo.legacy.shared.command.GetSchema)

Example 29 with GetSchema

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

the class RemoteDispatcherTest method commandShouldBeSentToServerIfThereAreNoProxiesAndNoPendingCommands.

@Test
public void commandShouldBeSentToServerIfThereAreNoProxiesAndNoPendingCommands() {
    // define our expectations
    expectRemoteCall(new GetSchema());
    replay(service);
    // trigger a call
    dispatcher.execute(new GetSchema(), makeNullCallback());
    processPendingCommands();
    // verify that the command was dispatched to the server
    verify(service);
}
Also used : GetSchema(org.activityinfo.legacy.shared.command.GetSchema) Test(org.junit.Test)

Example 30 with GetSchema

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

the class RemoteDispatcherTest method duplicateCommandsShouldBeMergedWithPendingRequests.

@Test
public void duplicateCommandsShouldBeMergedWithPendingRequests() {
    expectRemoteCall(new GetSchema());
    replay(service);
    // simulate successive dispatches of the same command from different
    // components of the application
    dispatcher.execute(new GetSchema(), makeNullCallback());
    dispatcher.execute(new GetSchema(), makeNullCallback());
    processPendingCommands();
    // verify that only one command was sent
    verify(service);
}
Also used : GetSchema(org.activityinfo.legacy.shared.command.GetSchema) Test(org.junit.Test)

Aggregations

GetSchema (org.activityinfo.legacy.shared.command.GetSchema)42 Test (org.junit.Test)27 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)22 UserDatabaseDTO (org.activityinfo.legacy.shared.model.UserDatabaseDTO)11 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)9 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)7 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)6 CreateEntity (org.activityinfo.legacy.shared.command.CreateEntity)4 UpdatePartner (org.activityinfo.legacy.shared.command.UpdatePartner)4 ActivityDTO (org.activityinfo.legacy.shared.model.ActivityDTO)4 CloneDatabase (org.activityinfo.legacy.shared.command.CloneDatabase)3 OnDataSet (org.activityinfo.server.database.OnDataSet)3 Delete (org.activityinfo.legacy.shared.command.Delete)2 DuplicateCreateResult (org.activityinfo.legacy.shared.command.result.DuplicateCreateResult)2 ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)2 CacheResult (org.activityinfo.ui.client.dispatch.remote.cache.CacheResult)2 NullCallback (com.bedatadriven.rebar.async.NullCallback)1 LocalDate (com.bedatadriven.rebar.time.calendar.LocalDate)1 BaseListLoadResult (com.extjs.gxt.ui.client.data.BaseListLoadResult)1 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)1