### Question:
PositionValidator extends BaseValidator { @Override public String validate() { String message = null; Map<ColumnType, ColumnDefinitionRow> typesToColumns = mapTypesToColumns(); if (typesToColumns.containsKey(ColumnType.LAT) || typesToColumns.containsKey(ColumnType.LON)) { ColumnDefinitionRow latColumn = typesToColumns.get(ColumnType.LAT); ColumnDefinitionRow lonColumn = typesToColumns.get(ColumnType.LON); if (latColumn == null) { message = ColumnType.LAT + " column is not identified."; } else if (lonColumn == null) { message = ColumnType.LON + " column is not identified."; } } else if (!typesToColumns.containsKey(ColumnType.POSITION) && !typesToColumns.containsKey(ColumnType.WKT_GEOMETRY) && !typesToColumns.containsKey(ColumnType.MGRS)) { message = "Selecting location columns is recommended."; } return message; } PositionValidator(ColumnDefinitionModel model); @Override String validate();  }### Answer:
@Test public void testValidate() { ColumnDefinitionModel model = new ColumnDefinitionModel(); ColumnDefinitionRow row1 = new ColumnDefinitionRow(); row1.setFormat("format"); row1.setIsImport(true); ColumnDefinitionRow row2 = new ColumnDefinitionRow(); row2.setFormat("format"); row2.setIsImport(true); model.getDefinitionTableModel().addRows(New.list(row1, row2)); row1.setDataType(ColumnType.LAT.toString()); row2.setDataType(ColumnType.LON.toString()); PositionValidator validator = new PositionValidator(model); assertNull(validator.validate()); row1.setDataType(ColumnType.POSITION.toString()); row2.setDataType(null); assertNull(validator.validate()); row1.setDataType(ColumnType.MGRS.toString()); assertNull(validator.validate()); row1.setDataType(ColumnType.WKT_GEOMETRY.toString()); assertNull(validator.validate()); }
@Test public void testValidateMissingColumns() { ColumnDefinitionModel model = new ColumnDefinitionModel(); ColumnDefinitionRow row1 = new ColumnDefinitionRow(); row1.setIsImport(true); ColumnDefinitionRow row2 = new ColumnDefinitionRow(); row2.setIsImport(true); model.getDefinitionTableModel().addRows(New.list(row1, row2)); PositionValidator validator = new PositionValidator(model); assertNotNull(validator.validate()); }
@Test public void testValidateMissingFormats() { ColumnDefinitionModel model = new ColumnDefinitionModel(); ColumnDefinitionRow row1 = new ColumnDefinitionRow(); row1.setIsImport(true); ColumnDefinitionRow row2 = new ColumnDefinitionRow(); row2.setIsImport(true); model.getDefinitionTableModel().addRows(New.list(row1, row2)); row1.setDataType(ColumnType.LAT.toString()); row2.setDataType(ColumnType.LON.toString()); PositionValidator validator = new PositionValidator(model); assertNull(validator.validate()); row1.setDataType(ColumnType.POSITION.toString()); row2.setDataType(null); assertNull(validator.validate()); row1.setDataType(ColumnType.MGRS.toString()); assertNull(validator.validate()); row1.setDataType(ColumnType.WKT_GEOMETRY.toString()); assertNull(validator.validate()); }
@Test public void testValidateMissingLatOrLon() { ColumnDefinitionModel model = new ColumnDefinitionModel(); ColumnDefinitionRow row1 = new ColumnDefinitionRow(); row1.setFormat("format"); row1.setIsImport(true); ColumnDefinitionRow row2 = new ColumnDefinitionRow(); row2.setFormat("format"); row2.setIsImport(true); model.getDefinitionTableModel().addRows(New.list(row1, row2)); row1.setDataType(ColumnType.LAT.toString()); PositionValidator validator = new PositionValidator(model); assertTrue(validator.validate().contains(ColumnType.LON.toString())); row1.setDataType(null); row2.setDataType(ColumnType.LON.toString()); assertTrue(validator.validate().contains(ColumnType.LAT.toString())); }