@Test public void testCheckRangeType_invalidPoint() { assertThat(captureThrowable(() -> checkRangeType("10", Type.POINT_TO_POINT, NO_BUS))) .isInstanceOf(IllegalArgumentException.class) .hasMessage("value must be between 11 and 99"); assertThat(captureThrowable(() -> checkRangeType("100", Type.POINT_TO_POINT, NO_BUS))) .isInstanceOf(IllegalArgumentException.class) .hasMessage("invalid length [1-2]"); assertThat(captureThrowable(() -> checkRangeType("11", Type.POINT_TO_POINT, "x"))) .isInstanceOf(IllegalArgumentException.class) .hasMessage("invalid bus size"); assertThat(captureThrowable(() -> checkRangeType("99", Type.POINT_TO_POINT, "x"))) .isInstanceOf(IllegalArgumentException.class) .hasMessage("invalid bus size"); assertThat(captureThrowable(() -> checkRangeType("10", Type.POINT_TO_POINT_BUS, NO_BUS))) .isInstanceOf(IllegalArgumentException.class) .hasMessage("value must be between 11 and 99"); assertThat(captureThrowable(() -> checkRangeType("100", Type.POINT_TO_POINT_BUS, NO_BUS))) .isInstanceOf(IllegalArgumentException.class) .hasMessage("invalid length [1-2]"); }
protected static void checkRangeType(String where, Type type, String bus) { checkNotNull(where, "invalid null value: [where]"); checkNotNull(type, "invalid null value: [type]"); checkNotNull(bus, "invalid null value: [bus]"); checkArgument(where.length() >= 1 && where.length() <= 2, "invalid length [1-2]"); switch (type) { case GENERAL: checkArgument(WHERE_GENERAL_VALUE.equals(where), "allowed value [0]"); checkArgument(bus.isEmpty(), "invalid bus size"); break; case GENERAL_BUS: checkArgument(WHERE_GENERAL_VALUE.equals(where), "allowed value [0]"); checkBus(bus); break; case AREA: checkRange(WHERE_MIN_VALUE_AREA, WHERE_MAX_VALUE_AREA, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case AREA_BUS: checkRange(WHERE_MIN_VALUE_AREA, WHERE_MAX_VALUE_AREA, checkIsInteger(where)); checkBus(bus); break; case GROUP: checkRange(WHERE_MIN_VALUE_GROUP, WHERE_MAX_VALUE_GROUP, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case GROUP_BUS: checkRange(WHERE_MIN_VALUE_GROUP, WHERE_MAX_VALUE_GROUP, checkIsInteger(where)); checkBus(bus); break; case POINT_TO_POINT: checkRange(WHERE_MIN_VALUE_POINT_TO_POINT, WHERE_MAX_VALUE_POINT_TO_POINT, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case POINT_TO_POINT_BUS: checkRange(WHERE_MIN_VALUE_POINT_TO_POINT, WHERE_MAX_VALUE_POINT_TO_POINT, checkIsInteger(where)); checkBus(bus); break; default: throw new IllegalArgumentException("invalid type"); } }
Automation extends BaseOpenMessage { protected static void checkRangeType(String where, Type type, String bus) { checkNotNull(where, "invalid null value: [where]"); checkNotNull(type, "invalid null value: [type]"); checkNotNull(bus, "invalid null value: [bus]"); checkArgument(where.length() >= 1 && where.length() <= 2, "invalid length [1-2]"); switch (type) { case GENERAL: checkArgument(WHERE_GENERAL_VALUE.equals(where), "allowed value [0]"); checkArgument(bus.isEmpty(), "invalid bus size"); break; case GENERAL_BUS: checkArgument(WHERE_GENERAL_VALUE.equals(where), "allowed value [0]"); checkBus(bus); break; case AREA: checkRange(WHERE_MIN_VALUE_AREA, WHERE_MAX_VALUE_AREA, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case AREA_BUS: checkRange(WHERE_MIN_VALUE_AREA, WHERE_MAX_VALUE_AREA, checkIsInteger(where)); checkBus(bus); break; case GROUP: checkRange(WHERE_MIN_VALUE_GROUP, WHERE_MAX_VALUE_GROUP, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case GROUP_BUS: checkRange(WHERE_MIN_VALUE_GROUP, WHERE_MAX_VALUE_GROUP, checkIsInteger(where)); checkBus(bus); break; case POINT_TO_POINT: checkRange(WHERE_MIN_VALUE_POINT_TO_POINT, WHERE_MAX_VALUE_POINT_TO_POINT, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case POINT_TO_POINT_BUS: checkRange(WHERE_MIN_VALUE_POINT_TO_POINT, WHERE_MAX_VALUE_POINT_TO_POINT, checkIsInteger(where)); checkBus(bus); break; default: throw new IllegalArgumentException("invalid type"); } } }
Automation extends BaseOpenMessage { protected static void checkRangeType(String where, Type type, String bus) { checkNotNull(where, "invalid null value: [where]"); checkNotNull(type, "invalid null value: [type]"); checkNotNull(bus, "invalid null value: [bus]"); checkArgument(where.length() >= 1 && where.length() <= 2, "invalid length [1-2]"); switch (type) { case GENERAL: checkArgument(WHERE_GENERAL_VALUE.equals(where), "allowed value [0]"); checkArgument(bus.isEmpty(), "invalid bus size"); break; case GENERAL_BUS: checkArgument(WHERE_GENERAL_VALUE.equals(where), "allowed value [0]"); checkBus(bus); break; case AREA: checkRange(WHERE_MIN_VALUE_AREA, WHERE_MAX_VALUE_AREA, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case AREA_BUS: checkRange(WHERE_MIN_VALUE_AREA, WHERE_MAX_VALUE_AREA, checkIsInteger(where)); checkBus(bus); break; case GROUP: checkRange(WHERE_MIN_VALUE_GROUP, WHERE_MAX_VALUE_GROUP, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case GROUP_BUS: checkRange(WHERE_MIN_VALUE_GROUP, WHERE_MAX_VALUE_GROUP, checkIsInteger(where)); checkBus(bus); break; case POINT_TO_POINT: checkRange(WHERE_MIN_VALUE_POINT_TO_POINT, WHERE_MAX_VALUE_POINT_TO_POINT, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case POINT_TO_POINT_BUS: checkRange(WHERE_MIN_VALUE_POINT_TO_POINT, WHERE_MAX_VALUE_POINT_TO_POINT, checkIsInteger(where)); checkBus(bus); break; default: throw new IllegalArgumentException("invalid type"); } } private  Automation(String value); }
Automation extends BaseOpenMessage { protected static void checkRangeType(String where, Type type, String bus) { checkNotNull(where, "invalid null value: [where]"); checkNotNull(type, "invalid null value: [type]"); checkNotNull(bus, "invalid null value: [bus]"); checkArgument(where.length() >= 1 && where.length() <= 2, "invalid length [1-2]"); switch (type) { case GENERAL: checkArgument(WHERE_GENERAL_VALUE.equals(where), "allowed value [0]"); checkArgument(bus.isEmpty(), "invalid bus size"); break; case GENERAL_BUS: checkArgument(WHERE_GENERAL_VALUE.equals(where), "allowed value [0]"); checkBus(bus); break; case AREA: checkRange(WHERE_MIN_VALUE_AREA, WHERE_MAX_VALUE_AREA, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case AREA_BUS: checkRange(WHERE_MIN_VALUE_AREA, WHERE_MAX_VALUE_AREA, checkIsInteger(where)); checkBus(bus); break; case GROUP: checkRange(WHERE_MIN_VALUE_GROUP, WHERE_MAX_VALUE_GROUP, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case GROUP_BUS: checkRange(WHERE_MIN_VALUE_GROUP, WHERE_MAX_VALUE_GROUP, checkIsInteger(where)); checkBus(bus); break; case POINT_TO_POINT: checkRange(WHERE_MIN_VALUE_POINT_TO_POINT, WHERE_MAX_VALUE_POINT_TO_POINT, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case POINT_TO_POINT_BUS: checkRange(WHERE_MIN_VALUE_POINT_TO_POINT, WHERE_MAX_VALUE_POINT_TO_POINT, checkIsInteger(where)); checkBus(bus); break; default: throw new IllegalArgumentException("invalid type"); } } private  Automation(String value); static Automation requestStop(String where); static Automation requestStop(String where, Type type, String bus); static Automation requestMoveUp(String where); static Automation requestMoveUp(String where, Type type, String bus); static Automation requestMoveDown(String where); static Automation requestMoveDown(String where, Type type, String bus); static Func1<OpenSession, OpenSession> handleResponse(Action0 onSuccess, Action0 onFail); static Automation requestStatus(String where); static Automation requestStatus(String where, Type type, String bus); static Func1<OpenSession, OpenSession> handleStatus(Action0 stopAction, Action0 upAction, Action0 downAction); static boolean isValidRangeType(String where, Type type, String bus); }
Automation extends BaseOpenMessage { protected static void checkRangeType(String where, Type type, String bus) { checkNotNull(where, "invalid null value: [where]"); checkNotNull(type, "invalid null value: [type]"); checkNotNull(bus, "invalid null value: [bus]"); checkArgument(where.length() >= 1 && where.length() <= 2, "invalid length [1-2]"); switch (type) { case GENERAL: checkArgument(WHERE_GENERAL_VALUE.equals(where), "allowed value [0]"); checkArgument(bus.isEmpty(), "invalid bus size"); break; case GENERAL_BUS: checkArgument(WHERE_GENERAL_VALUE.equals(where), "allowed value [0]"); checkBus(bus); break; case AREA: checkRange(WHERE_MIN_VALUE_AREA, WHERE_MAX_VALUE_AREA, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case AREA_BUS: checkRange(WHERE_MIN_VALUE_AREA, WHERE_MAX_VALUE_AREA, checkIsInteger(where)); checkBus(bus); break; case GROUP: checkRange(WHERE_MIN_VALUE_GROUP, WHERE_MAX_VALUE_GROUP, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case GROUP_BUS: checkRange(WHERE_MIN_VALUE_GROUP, WHERE_MAX_VALUE_GROUP, checkIsInteger(where)); checkBus(bus); break; case POINT_TO_POINT: checkRange(WHERE_MIN_VALUE_POINT_TO_POINT, WHERE_MAX_VALUE_POINT_TO_POINT, checkIsInteger(where)); checkArgument(bus.isEmpty(), "invalid bus size"); break; case POINT_TO_POINT_BUS: checkRange(WHERE_MIN_VALUE_POINT_TO_POINT, WHERE_MAX_VALUE_POINT_TO_POINT, checkIsInteger(where)); checkBus(bus); break; default: throw new IllegalArgumentException("invalid type"); } } private  Automation(String value); static Automation requestStop(String where); static Automation requestStop(String where, Type type, String bus); static Automation requestMoveUp(String where); static Automation requestMoveUp(String where, Type type, String bus); static Automation requestMoveDown(String where); static Automation requestMoveDown(String where, Type type, String bus); static Func1<OpenSession, OpenSession> handleResponse(Action0 onSuccess, Action0 onFail); static Automation requestStatus(String where); static Automation requestStatus(String where, Type type, String bus); static Func1<OpenSession, OpenSession> handleStatus(Action0 stopAction, Action0 upAction, Action0 downAction); static boolean isValidRangeType(String where, Type type, String bus);  }