/** * Tests the some misconfig-cases for the following config (position=3 means third WP, queue's * size=2). * * <pre> * 1.2 => urgend (not an int, shall be ignored, i.e. also "high", as this is the "closest" prio we have got this size) * 2-25 => high (OK) * 26-50 => mediummm (wrong spelling, shall be ignored, i.e. also "high") * 51-100 => low (OK) * >100 => minor (OK) * </pre> */ @Test public void testWrongSysConfig() { final SysconfigBackedSizeBasedWorkpackagePrioConfig config = new SysconfigBackedSizeBasedWorkpackagePrioConfig( Env.getCtx(), "testInternalName", ConstantWorkpackagePrio.low()); final String sysConfigPrefix = config.getSysConfigPrefix(); final ISysConfigBL iSysConfigBL = Services.get(ISysConfigBL.class); iSysConfigBL.setValue(sysConfigPrefix + "101", "minor", 0); iSysConfigBL.setValue(sysConfigPrefix + "51", "low", 0); iSysConfigBL.setValue(sysConfigPrefix + "25", "mediummm", 0); // wrong string, should be skipped iSysConfigBL.setValue(sysConfigPrefix + "2", "high", 0); iSysConfigBL.setValue( sysConfigPrefix + "1.2", "urgent", 0); // not an int number, should also be skipped assertThat("Priority for size=101", config.apply(101 - 1), is(ConstantWorkpackagePrio.minor())); assertThat("Priority for size=100", config.apply(100 - 1), is(ConstantWorkpackagePrio.low())); assertThat("Priority for size=99", config.apply(99 - 1), is(ConstantWorkpackagePrio.low())); assertThat("Priority for size=51", config.apply(51 - 1), is(ConstantWorkpackagePrio.low())); assertThat("Priority for size=50", config.apply(50 - 1), is(ConstantWorkpackagePrio.high())); assertThat( "Priority for size=49", config.apply(49 - 1), is( ConstantWorkpackagePrio .high())); // because there is no correct "medium", everything between 2 and 50 is // high // still low, because the value fore 25 has a wrong prio string assertThat("Priority for size=26", config.apply(26 - 1), is(ConstantWorkpackagePrio.high())); assertThat("Priority for size=25", config.apply(25 - 1), is(ConstantWorkpackagePrio.high())); assertThat("Priority for size=24", config.apply(24 - 1), is(ConstantWorkpackagePrio.high())); assertThat("Priority for size=2", config.apply(2 - 1), is(ConstantWorkpackagePrio.high())); // also/still high (not urgent), because there is no correct number string for 1 assertThat("Priority for size=1", config.apply(1 - 1), is(ConstantWorkpackagePrio.high())); }
/** * Tests the normal case (all configured "correctly") for the following config (position=3 means * third WP, queue's size=2). * * <pre> * 1 => urgend * 2 -5 => high * 6-15 => medium * 16-30 => low * >30 => minor * </pre> */ @Test public void testNormalSysConfig() { final SysconfigBackedSizeBasedWorkpackagePrioConfig config = new SysconfigBackedSizeBasedWorkpackagePrioConfig( Env.getCtx(), "testInternalName", ConstantWorkpackagePrio.low()); final String sysConfigPrefix = config.getSysConfigPrefix(); final ISysConfigBL sysConfigBL = Services.get(ISysConfigBL.class); sysConfigBL.setValue(sysConfigPrefix + "31", "minor", 0); sysConfigBL.setValue(sysConfigPrefix + "16", "low", 0); sysConfigBL.setValue(sysConfigPrefix + "0006", "medium", 0); // leading zeros shall not matter sysConfigBL.setValue(sysConfigPrefix + "02", "HIGH", 0); sysConfigBL.setValue(sysConfigPrefix + "1", "URgENT", 0); // cases shall not matter assertThat("Priority for size=100", config.apply(100), is(ConstantWorkpackagePrio.minor())); // assertThat( "Priority for position=31/size=30", config.apply(31 - 1), is(ConstantWorkpackagePrio.minor())); assertThat( "Priority for position=30/size=29", config.apply(30 - 1), is(ConstantWorkpackagePrio.low())); // assertThat( "Priority for position=16/size=15", config.apply(16 - 1), is(ConstantWorkpackagePrio.low())); assertThat( "Priority for position=15/size=14", config.apply(15 - 1), is(ConstantWorkpackagePrio.medium())); // still low, because there is no correct number string for 5 assertThat( "Priority for position=6/size=5", config.apply(6 - 1), is(ConstantWorkpackagePrio.medium())); assertThat( "Priority for position=5/size=4", config.apply(5 - 1), is(ConstantWorkpackagePrio.high())); assertThat( "Priority for position=2/size=1", config.apply(2 - 1), is(ConstantWorkpackagePrio.high())); assertThat( "Priority for position=1/size=0", config.apply(1 - 1), is(ConstantWorkpackagePrio.urgent())); // won't happen, but still works assertThat( "Priority for position=0/size=-1", config.apply(0), is(ConstantWorkpackagePrio.urgent())); }