예제 #1
0
 public void testCreateMultipleRowValidation(SheetValidation sheetValidation) {
   ErrorManager errorManager = sheetValidation.getErrorManager();
   boolean check = true;
   Validation validationError = null;
   try {
     PairMethodArguments test1 =
         new PairMethodArguments(RowValidation.MANDATORY_CELL_TEST, new String[] {"Column C"});
     PairMethodArguments test2 =
         new PairMethodArguments(RowValidation.MISSING_HEADER_TEST, new String[] {"Column B"});
     ArrayList<CreateValidation> rowValidations =
         sheetValidation.createMultipleRowValidation(
             new PairMethodArguments[] {test1, test2},
             new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});
     for (CreateValidation validation : rowValidations) {
       validationError = validation.getValidationType();
       check = validation.run();
       if (!check) {
         String message = ErrorManager.getErrorMessageFromTestId(validation.getTestId());
         StringBuffer errorToPrint =
             errorManager.createMessageFromErrorMessage(
                 message, new Object[] {validation.getValidationType().getErrorsFound()});
         System.out.print(errorToPrint);
         errorManager.printMessage(errorToPrint.toString());
       }
     }
   } catch (Exception e) {
     StringBuffer errorToPrint =
         errorManager.createMissingColumnMessage(
             ErrorManager.MISSING_COL_ERROR, validationError.getErrorsFound());
     System.err.println(errorToPrint);
     errorManager.printMessage(errorToPrint.toString());
   }
 }
예제 #2
0
 public void testExtraSpaces(SheetValidation sheetValidation) {
   String colC = "Column C";
   ColumnValidation validateColC = sheetValidation.createColumnValidation(colC);
   boolean check = validateColC.leadingTrailingSpaces();
   if (!check) {
     StringBuffer errorToPrint =
         sheetValidation
             .getErrorManager()
             .createMessage(ErrorManager.EXTRA_SPACES_ERROR, validateColC.getErrorsFound());
     System.out.println(errorToPrint);
     sheetValidation.getErrorManager().printMessage(errorToPrint.toString());
   }
 }
예제 #3
0
 public void testUniqueHeader(SheetValidation sheetValidation) {
   RowValidation validateHeader = sheetValidation.createRowValidation(0);
   boolean check = validateHeader.uniqueHeader();
   if (!check) {
     StringBuffer errorToPrint =
         sheetValidation
             .getErrorManager()
             .createDupFoundMessage(
                 ErrorManager.UNIQUENESS_ERROR, validateHeader.getMultipleErrorsFound(), ",");
     System.out.println(errorToPrint);
     sheetValidation.getErrorManager().printMessage(errorToPrint.toString());
   }
 }
예제 #4
0
 public void testUniqueValue(SheetValidation sheetValidation) {
   String colC = "Column C";
   ColumnValidation validateColC = sheetValidation.createColumnValidation(colC);
   boolean check = validateColC.uniqueValue();
   if (!check) {
     StringBuffer errorToPrint =
         sheetValidation
             .getErrorManager()
             .createDupFoundMessage(
                 ErrorManager.UNIQUENESS_ERROR, validateColC.getMultipleErrorsFound(), ",");
     System.out.println(errorToPrint);
     sheetValidation.getErrorManager().printMessage(errorToPrint.toString());
   }
 }
예제 #5
0
 public void testPatternAbsent(SheetValidation sheetValidation) {
   String colA = "Column A";
   ColumnValidation validateColA = sheetValidation.createColumnValidation(colA);
   String[] pattern = new String[] {".", "/"};
   boolean check = validateColA.isPatternAbsent(pattern);
   if (!check) {
     ErrorManager errorManager = sheetValidation.getErrorManager();
     String message =
         ErrorManager.PATTERN_DETECTED_ERROR + errorManager.getListOfTerms(pattern, " or ");
     StringBuffer errorToPrint =
         errorManager.createMessage(message, validateColA.getErrorsFound());
     System.out.println(errorToPrint);
     errorManager.printMessage(errorToPrint.toString());
   }
 }
예제 #6
0
 public void testPatternPresent(SheetValidation sheetValidation) {
   String colB = "Column B";
   ColumnValidation validateColB = sheetValidation.createColumnValidation(colB);
   String[] pattern = new String[] {".jpg", ".tiff"};
   boolean check = validateColB.isPatternPresent(pattern);
   if (!check) {
     ErrorManager errorManager = sheetValidation.getErrorManager();
     String message =
         ErrorManager.PATTERN_NOT_FOUND_ERROR + errorManager.getListOfTerms(pattern, " or ");
     StringBuffer errorToPrint =
         errorManager.createMessage(message, validateColB.getErrorsFound());
     System.out.println(errorToPrint);
     errorManager.printMessage(errorToPrint.toString());
   }
 }
예제 #7
0
 public void testDropDown(SheetValidation sheetValidation) {
   String colB = "Column B";
   String colDD = "Drop Down";
   ColumnValidation validation = sheetValidation.createColumnValidation(colB, colDD);
   boolean check = validation.dropDown();
   if (!check) {
     //			StringBuffer errorToPrint = sheetValidation.getErrorManager()
     //					.createDropDownMessage(ErrorManager.DROP_DOWN_ERROR,
     // validation.getMultipleErrorsFound());
     StringBuffer errorToPrint2 =
         sheetValidation
             .getErrorManager()
             .createMessageFromErrorMessage(
                 ErrorManager.DROP_DOWN_ERROR, new Object[] {validation.getMultipleErrorsFound()});
     System.out.println(errorToPrint2);
     //			sheetValidation.getErrorManager().printMessage(errorToPrint.toString());
   }
 }
예제 #8
0
 public void testMandatoryCells(SheetValidation sheetValidation) {
   RowValidation validateRowB = sheetValidation.createRowValidation(9);
   boolean check = true;
   ErrorManager errorManager = sheetValidation.getErrorManager();
   try {
     check = validateRowB.mandatoryCells("Column C");
     if (!check) {
       StringBuffer errorToPrint =
           errorManager.createMessage(
               ErrorManager.EMPTY_CELL_ERROR, validateRowB.getErrorsFound());
       System.out.print(errorToPrint);
       errorManager.printMessage(errorToPrint.toString());
     }
   } catch (MissingColumnException e) {
     StringBuffer errorToPrint =
         errorManager.createMissingColumnMessage(
             ErrorManager.MISSING_COL_ERROR, validateRowB.getErrorsFound());
     System.out.println(errorToPrint);
     errorManager.printMessage(errorToPrint.toString());
   }
 }