src/test/java/de/blau/android/osm/StorageDelegatorTest.java
/**
     * Add a member to a relation with low relation member limit
     */
Add a member to a relation with low relation member limit
Add a member to a relation with low relation member limit
@Test
    public void addMemberToRelationLimit() {
        App.newLogic();
        Logic logic = App.getLogic();
        Preferences prefs = new Preferences(ApplicationProvider.getApplicationContext());
        Server server = prefs.getServer();
        try {
            server.getCachedCapabilities().setMaxRelationMembers(1);
            logic.setPrefs(prefs);
            StorageDelegator d = new StorageDelegator();
            Way w = DelegatorUtil.addWayToStorage(d, false);
            Relation r = w.getParentRelations().get(0);
            try { 
                d.addMemberToRelation(new RelationMember("", w), r);
                fail("should have errored");
            } catch (OsmIllegalOperationException ex) {
                assertEquals(PreconditionIssue.RELATION_MEMBER_COUNT, ex.getIssue());
            }
        } finally {
            server.getCachedCapabilities().setMaxRelationMembers(32000);
        }
    }
@ Test public void addMemberToRelationLimit ( ) { App . newLogic ( ) ; Logic logic = App . getLogic ( ) ; Preferences prefs = new Preferences ( ApplicationProvider . getApplicationContext ( ) ) ; Server server = prefs . getServer ( ) ; try { server . getCachedCapabilities ( ) . setMaxRelationMembers ( 1 ) ; logic . setPrefs ( prefs ) ; StorageDelegator d = new StorageDelegator ( ) ; Way w = DelegatorUtil . addWayToStorage ( d , false ) ; Relation r = w . getParentRelations ( ) . get ( 0 ) ; try { d . addMemberToRelation ( new RelationMember ( "" , w ) , r ) ; fail ( "should have errored" ) ; } catch ( OsmIllegalOperationException ex ) { assertEquals ( PreconditionIssue . RELATION_MEMBER_COUNT , ex . getIssue ( ) ) ; } } finally { server . getCachedCapabilities ( ) . setMaxRelationMembers ( 32000 ) ; } }
Add a member to a relation with low relation member limit
Add a member to a relation with low relation member limit
// simply add w again to exceed the limit // expected