ValidationUtils { public static boolean dataValueIsZeroAndInsignificant( String value, DataElement dataElement ) { AggregationType aggregationType = dataElement.getAggregationType(); return dataElement.getValueType().isNumeric() && MathUtils.isZero( value ) && !dataElement.isZeroIsSignificant() && !( aggregationType == AggregationType.AVERAGE_SUM_ORG_UNIT || aggregationType == AggregationType.AVERAGE ); }  static boolean expressionIsValidSQl( String filter ); static boolean emailIsValid( String email ); static boolean dateIsValid( String date, Locale locale ); static boolean dateIsValid( String date ); static boolean timeIsValid( String time ); static boolean urlIsValid( String url ); static boolean uuidIsValid( String uuid ); static boolean usernameIsValid( String username ); static boolean passwordIsValid( String password ); static boolean coordinateIsValid( String coordinate ); static boolean bboxIsValid( String bbox ); static String getLongitude( String coordinate ); static String getLatitude( String coordinate ); static Point2D getCoordinatePoint2D( String coordinate ); static String getCoordinate( String longitude, String latitude ); static String dataValueIsValid( String value, DataElement dataElement ); static String dataValueIsValid( String value, ValueType valueType ); static boolean dataValueIsZeroAndInsignificant( String value, DataElement dataElement ); static String commentIsValid( String comment ); static String storedByIsValid( String storedBy ); static boolean isValidHexColor( String value ); static Object getSubstitutionValue( ValueType valueType ); static String normalizeBoolean( String bool, ValueType valueType ); static boolean validateRenderingType( Class<?> clazz, ValueType valueType, boolean optionSet, ValueTypeRenderingType type ); static boolean validateWhatsapp( String whatsapp ); static boolean validateInternationalPhoneNumber( String phoneNumber ); static final ImmutableSet<String> ILLEGAL_SQL_KEYWORDS; }
@Test public void testDataValueIsZeroAndInsignificant() { DataElement de = new DataElement( "DEA" ); de.setValueType( ValueType.INTEGER ); de.setAggregationType( AggregationType.SUM ); assertTrue( dataValueIsZeroAndInsignificant( "0", de ) ); de.setAggregationType( AggregationType.AVERAGE_SUM_ORG_UNIT ); assertFalse( dataValueIsZeroAndInsignificant( "0", de ) ); }