private DefaultIncrementalAttributeState(String actualAttributeName, int pageSize) { this.actualAttributeName = actualAttributeName; this.pageSize = pageSize; this.requestRange = new RangeOption(0, pageSize); }
private DefaultIncrementalAttributeState(String actualAttributeName, int pageSize) { this.actualAttributeName = actualAttributeName; this.pageSize = pageSize; this.requestRange = new RangeOption(0, pageSize); }
private DefaultIncrementalAttributeState(String actualAttributeName, int pageSize) { this.actualAttributeName = actualAttributeName; this.pageSize = pageSize; this.requestRange = new RangeOption(0, pageSize); }
private DefaultIncrementalAttributeState(String actualAttributeName, int pageSize) { this.actualAttributeName = actualAttributeName; this.pageSize = pageSize; this.requestRange = new RangeOption(0, pageSize); }
public static RangeOption parse(String option) { Matcher rangeMatcher = RANGE_PATTERN.matcher(option); rangeMatcher.find(); if (!rangeMatcher.matches()) { return null; } String initialStr = rangeMatcher.group(1); int initial = Integer.parseInt(initialStr); int terminal = TERMINAL_MISSING; if (rangeMatcher.group(2) != null) { String terminalStr = rangeMatcher.group(3); if ("*".equals(terminalStr)) { terminal = TERMINAL_END_OF_RANGE; } else { terminal = Integer.parseInt(terminalStr); } } return new RangeOption(initial, terminal); }
public static RangeOption parse(String option) { Matcher rangeMatcher = RANGE_PATTERN.matcher(option); rangeMatcher.find(); if (!rangeMatcher.matches()) { return null; } String initialStr = rangeMatcher.group(1); int initial = Integer.parseInt(initialStr); int terminal = TERMINAL_MISSING; if (rangeMatcher.group(2) != null) { String terminalStr = rangeMatcher.group(3); if ("*".equals(terminalStr)) { terminal = TERMINAL_END_OF_RANGE; } else { terminal = Integer.parseInt(terminalStr); } } return new RangeOption(initial, terminal); }
public static RangeOption parse(String option) { Matcher rangeMatcher = RANGE_PATTERN.matcher(option); rangeMatcher.find(); if (!rangeMatcher.matches()) { return null; } String initialStr = rangeMatcher.group(1); int initial = Integer.parseInt(initialStr); int terminal = TERMINAL_MISSING; if (rangeMatcher.group(2) != null) { String terminalStr = rangeMatcher.group(3); if ("*".equals(terminalStr)) { terminal = TERMINAL_END_OF_RANGE; } else { terminal = Integer.parseInt(terminalStr); } } return new RangeOption(initial, terminal); }
public static RangeOption parse(String option) { Matcher rangeMatcher = RANGE_PATTERN.matcher(option); rangeMatcher.find(); if (!rangeMatcher.matches()) { return null; } String initialStr = rangeMatcher.group(1); int initial = Integer.parseInt(initialStr); int terminal = TERMINAL_MISSING; if (rangeMatcher.group(2) != null) { String terminalStr = rangeMatcher.group(3); if ("*".equals(terminalStr)) { terminal = TERMINAL_END_OF_RANGE; } else { terminal = Integer.parseInt(terminalStr); } } return new RangeOption(initial, terminal); }
public RangeOption nextRange(int pageSize) { if (getTerminal() < 0) { throw new IllegalStateException("Cannot generate next range, range-terminal: " + getTerminal()); } if (pageSize < 0 && pageSize != TERMINAL_END_OF_RANGE) { throw new IllegalArgumentException("Invalid page size: " + pageSize); } int initial = getTerminal() + 1; int terminal = pageSize == TERMINAL_END_OF_RANGE ? TERMINAL_END_OF_RANGE : getTerminal() + pageSize; return new RangeOption(initial, terminal); } }
public RangeOption nextRange(int pageSize) { if (getTerminal() < 0) { throw new IllegalStateException("Cannot generate next range, range-terminal: " + getTerminal()); } if (pageSize < 0 && pageSize != TERMINAL_END_OF_RANGE) { throw new IllegalArgumentException("Invalid page size: " + pageSize); } int initial = getTerminal() + 1; int terminal = pageSize == TERMINAL_END_OF_RANGE ? TERMINAL_END_OF_RANGE : getTerminal() + pageSize; return new RangeOption(initial, terminal); } }
public RangeOption nextRange(int pageSize) { if (getTerminal() < 0) { throw new IllegalStateException("Cannot generate next range, range-terminal: " + getTerminal()); } if (pageSize < 0 && pageSize != TERMINAL_END_OF_RANGE) { throw new IllegalArgumentException("Invalid page size: " + pageSize); } int initial = getTerminal() + 1; int terminal = pageSize == TERMINAL_END_OF_RANGE ? TERMINAL_END_OF_RANGE : getTerminal() + pageSize; return new RangeOption(initial, terminal); } }
public RangeOption nextRange(int pageSize) { if (getTerminal() < 0) { throw new IllegalStateException("Cannot generate next range, range-terminal: " + getTerminal()); } if (pageSize < 0 && pageSize != TERMINAL_END_OF_RANGE) { throw new IllegalArgumentException("Invalid page size: " + pageSize); } int initial = getTerminal() + 1; int terminal = pageSize == TERMINAL_END_OF_RANGE ? TERMINAL_END_OF_RANGE : getTerminal() + pageSize; return new RangeOption(initial, terminal); } }
@Test public void testToString() throws Exception { RangeOption range = new RangeOption(0, 100); assertThat(range.toString()).isEqualTo("Range=0-100"); range = new RangeOption(0, RangeOption.TERMINAL_END_OF_RANGE); assertThat(range.toString()).isEqualTo("Range=0-*"); range = new RangeOption(0, RangeOption.TERMINAL_MISSING); assertThat(range.toString()).isEqualTo("Range=0"); }
@Test public void testConstructorInvalid() { try { new RangeOption(101, 100); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { assertThat(true).isTrue(); } try { new RangeOption(-1, 100); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { assertThat(true).isTrue(); } try { new RangeOption(-10, 100); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { assertThat(true).isTrue(); } try { new RangeOption(0, -3); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { assertThat(true).isTrue(); } }
@Test public void testLoop() throws Exception { Attributes attributes = createAttributes("member", new RangeOption(0, 10)); tested.mapFromAttributes(attributes); assertThat(tested.hasMore()).isTrue(); assertThat(tested.getValues("member")).hasSize(11); attributes = createAttributes("member", new RangeOption(11), 5); tested.mapFromAttributes(attributes); assertThat(tested.hasMore()).isFalse(); assertThat(tested.getValues("member")).hasSize(16); }
@Test public void test2LoopsWithPageSizeExact() throws Exception { tested = new DefaultIncrementalAttributesMapper(20, "member"); Attributes attributes = createAttributes("member", new RangeOption(0, 10)); tested.mapFromAttributes(attributes); assertThat(tested.hasMore()).isTrue(); assertThat(tested.getValues("member")).hasSize(11); attributes = createAttributes("member", new RangeOption(11, 30)); tested.mapFromAttributes(attributes); assertThat(tested.hasMore()).isFalse(); assertThat(tested.getValues("member")).hasSize(31); }
@Test public void test2LoopsWithPageSize() throws Exception { tested = new DefaultIncrementalAttributesMapper(20, "member"); Attributes attributes = createAttributes("member", new RangeOption(0, 10)); tested.mapFromAttributes(attributes); assertThat(tested.hasMore()).isTrue(); assertThat(tested.getValues("member")).hasSize(11); attributes = createAttributes("member", new RangeOption(11), 5); tested.mapFromAttributes(attributes); assertThat(tested.hasMore()).isFalse(); assertThat(tested.getValues("member")).hasSize(16); }
@Test public void testLoopWithTwoRangedAttributesLoopOnOneAttribute() throws Exception { tested = new DefaultIncrementalAttributesMapper(10, new String[]{"member", "cn"}); Attributes attributes = createAttributes("member", new RangeOption(0, 5)); attributes.put(createRangeAttribute("cn", new RangeOption(0, 10), 10)); tested.mapFromAttributes(attributes); assertThat(tested.hasMore()).isTrue(); assertThat(tested.getValues("member")).hasSize(6); assertThat(tested.getValues("cn")).hasSize(10); assertThat(tested.getAttributesForLookup().length).isEqualTo(1); attributes = createAttributes("member", new RangeOption(6), 5); tested.mapFromAttributes(attributes); assertThat(tested.hasMore()).isFalse(); assertThat(tested.getValues("member")).hasSize(11); }
@Test public void test1LoopWithPageSizeExact() throws Exception { tested = new DefaultIncrementalAttributesMapper(10, "member"); Attributes attributes = createAttributes("member", new RangeOption(0, 10)); tested.mapFromAttributes(attributes); assertThat(tested.hasMore()).isFalse(); assertThat(tested.getValues("member")).hasSize(11); }