@Test(expected = IllegalStateException.class) public void testValidateMeasureNamesDuplicated() throws IOException { File f = new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/ssb.json"); CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class); MeasureDesc measureDescDuplicated = desc.getMeasures().get(1); List<MeasureDesc> newMeasures = Lists.newArrayList(desc.getMeasures()); newMeasures.add(measureDescDuplicated); desc.setMeasures(newMeasures); desc.init(config); }
private boolean validateMeasureNamesDuplicated(List<MeasureDesc> measures, ValidateContext context) { Set<String> nameSet = new HashSet<>(); for (MeasureDesc measure: measures){ if (nameSet.contains(measure.getName())){ context.addResult(ResultLevel.ERROR, "There is duplicated measure's name: " + measure.getName()); return true; } else { nameSet.add(measure.getName()); } } return false; }
FunctionRule implements IValidatorRule<CubeDesc> { private boolean validateMeasureNamesDuplicated(List<MeasureDesc> measures, ValidateContext context) { Set<String> nameSet = new HashSet<>(); for (MeasureDesc measure: measures){ if (nameSet.contains(measure.getName())){ context.addResult(ResultLevel.ERROR, "There is duplicated measure's name: " + measure.getName()); return true; } else { nameSet.add(measure.getName()); } } return false; } }
FunctionRule implements IValidatorRule<CubeDesc> { private boolean validateMeasureNamesDuplicated(List<MeasureDesc> measures, ValidateContext context) { Set<String> nameSet = new HashSet<>(); for (MeasureDesc measure: measures){ if (nameSet.contains(measure.getName())){ context.addResult(ResultLevel.ERROR, "There is duplicated measure's name: " + measure.getName()); return true; } else { nameSet.add(measure.getName()); } } return false; }  }
FunctionRule implements IValidatorRule<CubeDesc> { private boolean validateMeasureNamesDuplicated(List<MeasureDesc> measures, ValidateContext context) { Set<String> nameSet = new HashSet<>(); for (MeasureDesc measure: measures){ if (nameSet.contains(measure.getName())){ context.addResult(ResultLevel.ERROR, "There is duplicated measure's name: " + measure.getName()); return true; } else { nameSet.add(measure.getName()); } } return false; }  @Override void validate(CubeDesc cube, ValidateContext context); }
FunctionRule implements IValidatorRule<CubeDesc> { private boolean validateMeasureNamesDuplicated(List<MeasureDesc> measures, ValidateContext context) { Set<String> nameSet = new HashSet<>(); for (MeasureDesc measure: measures){ if (nameSet.contains(measure.getName())){ context.addResult(ResultLevel.ERROR, "There is duplicated measure's name: " + measure.getName()); return true; } else { nameSet.add(measure.getName()); } } return false; }  @Override void validate(CubeDesc cube, ValidateContext context);  }