@Test public void parseRegion_illegalCoordinateCombination_IllegalArgumentException() throws Exception { final String str = "2,-1,1,-1"; exception.expect(IllegalArgumentException.class); InputParser.parseRegion(str); }
public static Region parseRegion(String value) { if (StringUtils.isEmpty(value)) { throw new IllegalArgumentException(String.format(ExceptionMsgs.INVALID_VALUE_FOR_INPUT, value, InputNames.REGION)); } String[] coords = value.split("[,]"); if (coords.length != 4) { throw new IllegalArgumentException(ExceptionMsgs.INVALID_NR_OF_COORDS); } int left = Integer.parseInt(coords[0]); int top = Integer.parseInt(coords[1]); int right = Integer.parseInt(coords[2]); int bottom = Integer.parseInt(coords[3]); return new Region(left, top, right, bottom); }
InputParser { public static Region parseRegion(String value) { if (StringUtils.isEmpty(value)) { throw new IllegalArgumentException(String.format(ExceptionMsgs.INVALID_VALUE_FOR_INPUT, value, InputNames.REGION)); } String[] coords = value.split("[,]"); if (coords.length != 4) { throw new IllegalArgumentException(ExceptionMsgs.INVALID_NR_OF_COORDS); } int left = Integer.parseInt(coords[0]); int top = Integer.parseInt(coords[1]); int right = Integer.parseInt(coords[2]); int bottom = Integer.parseInt(coords[3]); return new Region(left, top, right, bottom); } }
InputParser { public static Region parseRegion(String value) { if (StringUtils.isEmpty(value)) { throw new IllegalArgumentException(String.format(ExceptionMsgs.INVALID_VALUE_FOR_INPUT, value, InputNames.REGION)); } String[] coords = value.split("[,]"); if (coords.length != 4) { throw new IllegalArgumentException(ExceptionMsgs.INVALID_NR_OF_COORDS); } int left = Integer.parseInt(coords[0]); int top = Integer.parseInt(coords[1]); int right = Integer.parseInt(coords[2]); int bottom = Integer.parseInt(coords[3]); return new Region(left, top, right, bottom); } private  InputParser(); }
InputParser { public static Region parseRegion(String value) { if (StringUtils.isEmpty(value)) { throw new IllegalArgumentException(String.format(ExceptionMsgs.INVALID_VALUE_FOR_INPUT, value, InputNames.REGION)); } String[] coords = value.split("[,]"); if (coords.length != 4) { throw new IllegalArgumentException(ExceptionMsgs.INVALID_NR_OF_COORDS); } int left = Integer.parseInt(coords[0]); int top = Integer.parseInt(coords[1]); int right = Integer.parseInt(coords[2]); int bottom = Integer.parseInt(coords[3]); return new Region(left, top, right, bottom); } private  InputParser(); static String parseDescription(String descr); static short parseShort(String value, String inputName); static int parseInt(String value, String inputName); static boolean parseBoolean(String value, String inputName); static Region parseRegion(String value); static T parseEnum(String value, Class<T> clazz, String inputName); }
InputParser { public static Region parseRegion(String value) { if (StringUtils.isEmpty(value)) { throw new IllegalArgumentException(String.format(ExceptionMsgs.INVALID_VALUE_FOR_INPUT, value, InputNames.REGION)); } String[] coords = value.split("[,]"); if (coords.length != 4) { throw new IllegalArgumentException(ExceptionMsgs.INVALID_NR_OF_COORDS); } int left = Integer.parseInt(coords[0]); int top = Integer.parseInt(coords[1]); int right = Integer.parseInt(coords[2]); int bottom = Integer.parseInt(coords[3]); return new Region(left, top, right, bottom); } private  InputParser(); static String parseDescription(String descr); static short parseShort(String value, String inputName); static int parseInt(String value, String inputName); static boolean parseBoolean(String value, String inputName); static Region parseRegion(String value); static T parseEnum(String value, Class<T> clazz, String inputName);  }