use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.
the class RemoteDispatcherTest method commandExceptionsShouldBeCalledBackWithFailure.
@Test
public void commandExceptionsShouldBeCalledBackWithFailure() {
expectRemoteCall(new GetSchema());
// remote call succeeded,
andCallbackWihSuccess(new CommandException());
// command failed
replay(service);
AsyncCallback callback = makeCallbackThatExpectsFailure();
dispatcher.execute(new GetSchema(), callback);
processPendingCommands();
verify(service, callback);
}
use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.
the class CloneDatabaseTest method cloneWithDifferentCountry.
// https://bedatadriven.atlassian.net/browse/AI-315
// it seems that the problem occurs when there is a classic form with a "Village" location. If you change countries,
// you need to change the locationTypeId to a location type in the new country. Users can change the location type afterwards,
// so I would suggest that we apply a simple rule:
//
// 1. If there is a location type with the same name in the new country, use that location Type
// 2. if the source locationtype is bound to an adminlevel, choose the first root adminlevel in the new country
// 3. If the source locationtype is the null location type ( = Country) then the use the corresponding null locationtype in the new form
// 4. Otherwise use the "Village" location type in the target country.
@Test
public void cloneWithDifferentCountry() throws CommandException {
SchemaDTO schema = execute(new GetSchema());
UserDatabaseDTO pearDb = schema.getDatabaseById(PEAR_DATABASE_ID);
CloneDatabase cloneDatabase = new CloneDatabase().setSourceDatabaseId(pearDb.getId()).setCopyData(false).setCopyPartners(true).setCopyUserPermissions(true).setCountryId(UKRAINE_COUNTRY_ID).setName("PearClone").setDescription("PearClone Description");
CreateResult cloneResult = execute(cloneDatabase);
assertNotEquals(cloneResult.getNewId(), pearDb.getId());
assertDbCloned(cloneResult.getNewId(), pearDb.getId(), cloneDatabase);
}
use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.
the class CloneDatabaseTest method fullClone.
@Test
public void fullClone() throws CommandException {
SchemaDTO schema = execute(new GetSchema());
UserDatabaseDTO pearDb = schema.getDatabaseById(PEAR_DATABASE_ID);
CloneDatabase cloneDatabase = new CloneDatabase().setSourceDatabaseId(pearDb.getId()).setCopyData(true).setCopyPartners(true).setCopyUserPermissions(true).setCountryId(pearDb.getCountry().getId()).setName("PearClone").setDescription("PearClone Description");
CreateResult cloneResult = execute(cloneDatabase);
assertNotEquals(cloneResult.getNewId(), pearDb.getId());
assertDbCloned(cloneResult.getNewId(), pearDb.getId(), cloneDatabase);
// todo assert data copy
}
use of org.activityinfo.legacy.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")));
}
use of org.activityinfo.legacy.shared.command.GetSchema in project activityinfo by bedatadriven.
the class DeleteTest method testDeleteActivity.
@Test
public void testDeleteActivity() throws CommandException {
ActivityFormDTO form = execute(new GetActivityForm(1));
execute(new Delete(form));
execute(new Delete("Activity", 4));
SchemaDTO schema = execute(new GetSchema());
assertNull("delete by entity reference", schema.getActivityById(1));
assertNull("delete by id", schema.getActivityById(4));
}
Aggregations