@Test public void testValidateStatus() { try { InputValidator.validateStatusAndCheckNotDeleted("c","m","ACTIVE"); } catch (InvalidParameterException e) { fail("Non null should not fail"); } try { InputValidator.validateStatusAndCheckNotDeleted("c","m","DELETED"); } catch (InvalidParameterException e) { System.out.println("Expected error message " + e.getReportedErrorMessageId()); if (e.getReportedErrorMessage().contains("{") || e.getReportedErrorMessage().contains("}") ){ fail("inserts not correct"); } } try { InputValidator.validateStatusAndCheckNotDeleted("c","m","DANCER"); } catch (InvalidParameterException e) { System.out.println("Expected error message " + e.getReportedErrorMessageId()); if (e.getReportedErrorMessage().contains("{") || e.getReportedErrorMessage().contains("}") ){ fail("inserts not correct"); } } }
static public Status validateStatusAndCheckNotDeleted( String className, String actionDescription, String statusName) throws InvalidParameterException { Status newStatus = null; try { newStatus = Status.valueOf(statusName); } catch (Exception e) { ExceptionMessageDefinition messageDefinition = SubjectAreaErrorCode.INVALID_STATUS_VALUE_SUPPLIED.getMessageDefinition(); String invalidPropertyName = "status"; messageDefinition.setMessageParameters(invalidPropertyName, null); throw new InvalidParameterException(messageDefinition, className, actionDescription, invalidPropertyName, statusName); } if (Status.DELETED == newStatus) { ExceptionMessageDefinition messageDefinition = SubjectAreaErrorCode.STATUS_UPDATE_TO_DELETED_NOT_ALLOWED.getMessageDefinition(); String invalidPropertyName = "status"; messageDefinition.setMessageParameters(invalidPropertyName, null); throw new InvalidParameterException(messageDefinition, className, actionDescription, invalidPropertyName, statusName); } return newStatus; }
InputValidator { static public Status validateStatusAndCheckNotDeleted( String className, String actionDescription, String statusName) throws InvalidParameterException { Status newStatus = null; try { newStatus = Status.valueOf(statusName); } catch (Exception e) { ExceptionMessageDefinition messageDefinition = SubjectAreaErrorCode.INVALID_STATUS_VALUE_SUPPLIED.getMessageDefinition(); String invalidPropertyName = "status"; messageDefinition.setMessageParameters(invalidPropertyName, null); throw new InvalidParameterException(messageDefinition, className, actionDescription, invalidPropertyName, statusName); } if (Status.DELETED == newStatus) { ExceptionMessageDefinition messageDefinition = SubjectAreaErrorCode.STATUS_UPDATE_TO_DELETED_NOT_ALLOWED.getMessageDefinition(); String invalidPropertyName = "status"; messageDefinition.setMessageParameters(invalidPropertyName, null); throw new InvalidParameterException(messageDefinition, className, actionDescription, invalidPropertyName, statusName); } return newStatus; } }
InputValidator { static public Status validateStatusAndCheckNotDeleted( String className, String actionDescription, String statusName) throws InvalidParameterException { Status newStatus = null; try { newStatus = Status.valueOf(statusName); } catch (Exception e) { ExceptionMessageDefinition messageDefinition = SubjectAreaErrorCode.INVALID_STATUS_VALUE_SUPPLIED.getMessageDefinition(); String invalidPropertyName = "status"; messageDefinition.setMessageParameters(invalidPropertyName, null); throw new InvalidParameterException(messageDefinition, className, actionDescription, invalidPropertyName, statusName); } if (Status.DELETED == newStatus) { ExceptionMessageDefinition messageDefinition = SubjectAreaErrorCode.STATUS_UPDATE_TO_DELETED_NOT_ALLOWED.getMessageDefinition(); String invalidPropertyName = "status"; messageDefinition.setMessageParameters(invalidPropertyName, null); throw new InvalidParameterException(messageDefinition, className, actionDescription, invalidPropertyName, statusName); } return newStatus; }  }
InputValidator { static public Status validateStatusAndCheckNotDeleted( String className, String actionDescription, String statusName) throws InvalidParameterException { Status newStatus = null; try { newStatus = Status.valueOf(statusName); } catch (Exception e) { ExceptionMessageDefinition messageDefinition = SubjectAreaErrorCode.INVALID_STATUS_VALUE_SUPPLIED.getMessageDefinition(); String invalidPropertyName = "status"; messageDefinition.setMessageParameters(invalidPropertyName, null); throw new InvalidParameterException(messageDefinition, className, actionDescription, invalidPropertyName, statusName); } if (Status.DELETED == newStatus) { ExceptionMessageDefinition messageDefinition = SubjectAreaErrorCode.STATUS_UPDATE_TO_DELETED_NOT_ALLOWED.getMessageDefinition(); String invalidPropertyName = "status"; messageDefinition.setMessageParameters(invalidPropertyName, null); throw new InvalidParameterException(messageDefinition, className, actionDescription, invalidPropertyName, statusName); } return newStatus; }  static void validateRemoteServerURLNotNull(String className, String actionDescription, String omasServerURL); static void validateRemoteServerNameNotNull(String className, String actionDescription, String omasServerName); static void validateUserIdNotNull(
            String className,
            String actionDescription,
            String userId); static Status validateStatusAndCheckNotDeleted(
            String className,
            String actionDescription,
            String statusName); static void validateGUIDNotNull(
            String className,
            String actionDescription,
            String guid,
            String guidParameter); static void validateNameNotNull(String className,
                                           String actionDescription,
                                           String name,
                                           String nameParameter
                                          ); static void validateNodeType(Object... args); }
InputValidator { static public Status validateStatusAndCheckNotDeleted( String className, String actionDescription, String statusName) throws InvalidParameterException { Status newStatus = null; try { newStatus = Status.valueOf(statusName); } catch (Exception e) { ExceptionMessageDefinition messageDefinition = SubjectAreaErrorCode.INVALID_STATUS_VALUE_SUPPLIED.getMessageDefinition(); String invalidPropertyName = "status"; messageDefinition.setMessageParameters(invalidPropertyName, null); throw new InvalidParameterException(messageDefinition, className, actionDescription, invalidPropertyName, statusName); } if (Status.DELETED == newStatus) { ExceptionMessageDefinition messageDefinition = SubjectAreaErrorCode.STATUS_UPDATE_TO_DELETED_NOT_ALLOWED.getMessageDefinition(); String invalidPropertyName = "status"; messageDefinition.setMessageParameters(invalidPropertyName, null); throw new InvalidParameterException(messageDefinition, className, actionDescription, invalidPropertyName, statusName); } return newStatus; }  static void validateRemoteServerURLNotNull(String className, String actionDescription, String omasServerURL); static void validateRemoteServerNameNotNull(String className, String actionDescription, String omasServerName); static void validateUserIdNotNull(
            String className,
            String actionDescription,
            String userId); static Status validateStatusAndCheckNotDeleted(
            String className,
            String actionDescription,
            String statusName); static void validateGUIDNotNull(
            String className,
            String actionDescription,
            String guid,
            String guidParameter); static void validateNameNotNull(String className,
                                           String actionDescription,
                                           String name,
                                           String nameParameter
                                          ); static void validateNodeType(Object... args);  }