@Test public void testNameGetObfuscationExample() { NameObfuscatorInfo obfuscatorInfo = new NameObfuscatorInfo(); double obfuscationLevel = -1.0; String expected = "\"John Smith\" will become \" \" (anonymous)"; String actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); obfuscationLevel = -0.99; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); obfuscationLevel = 0.0; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); obfuscationLevel = 0.01; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); obfuscationLevel = 0.19; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); expected = "\"John Smith\" will become \"J. S.\""; obfuscationLevel = 0.2; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); obfuscationLevel = 0.21; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); obfuscationLevel = 0.39; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); expected = "\"John Smith\" will become \"John S.\""; obfuscationLevel = 0.4; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); obfuscationLevel = 0.41; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); obfuscationLevel = 0.59; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); expected = "\"John Smith\" will become \"J. Smith\""; obfuscationLevel = 0.6; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); obfuscationLevel = 0.61; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); obfuscationLevel = 0.79; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); expected = "\"John Smith\" will become \"John Smith\" (no change)"; obfuscationLevel = 0.8; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); obfuscationLevel = 0.81; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); obfuscationLevel = 1.0; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); obfuscationLevel = 2.0; actual = obfuscatorInfo.getObfuscationExample(obfuscationLevel); LOG.info("For "+obfuscationLevel+": Expected: \""+expected+"\" and was: \""+actual+"\""); Assert.assertEquals(expected, actual); }
public String getObfuscationExample(double obfuscationLevel) { if (null == obfuscationExamples || obfuscationExamples.size() <= 0) { return ""; } int index = 0; double previous = 0.0; String previousExample = ""; for(Entry<Double, String> entry : obfuscationExamples.entrySet()) { double current = entry.getKey().doubleValue(); if (0 == index) { previousExample = entry.getValue(); previous = -50000.0; index++; continue; } if (obfuscationLevel == previous || (obfuscationLevel >= previous && obfuscationLevel < current)) { return previousExample; } previousExample = entry.getValue(); previous = current; } return previousExample; }
ObfuscatorInfo { public String getObfuscationExample(double obfuscationLevel) { if (null == obfuscationExamples || obfuscationExamples.size() <= 0) { return ""; } int index = 0; double previous = 0.0; String previousExample = ""; for(Entry<Double, String> entry : obfuscationExamples.entrySet()) { double current = entry.getKey().doubleValue(); if (0 == index) { previousExample = entry.getValue(); previous = -50000.0; index++; continue; } if (obfuscationLevel == previous || (obfuscationLevel >= previous && obfuscationLevel < current)) { return previousExample; } previousExample = entry.getValue(); previous = current; } return previousExample; } }
ObfuscatorInfo { public String getObfuscationExample(double obfuscationLevel) { if (null == obfuscationExamples || obfuscationExamples.size() <= 0) { return ""; } int index = 0; double previous = 0.0; String previousExample = ""; for(Entry<Double, String> entry : obfuscationExamples.entrySet()) { double current = entry.getKey().doubleValue(); if (0 == index) { previousExample = entry.getValue(); previous = -50000.0; index++; continue; } if (obfuscationLevel == previous || (obfuscationLevel >= previous && obfuscationLevel < current)) { return previousExample; } previousExample = entry.getValue(); previous = current; } return previousExample; }  }
ObfuscatorInfo { public String getObfuscationExample(double obfuscationLevel) { if (null == obfuscationExamples || obfuscationExamples.size() <= 0) { return ""; } int index = 0; double previous = 0.0; String previousExample = ""; for(Entry<Double, String> entry : obfuscationExamples.entrySet()) { double current = entry.getKey().doubleValue(); if (0 == index) { previousExample = entry.getValue(); previous = -50000.0; index++; continue; } if (obfuscationLevel == previous || (obfuscationLevel >= previous && obfuscationLevel < current)) { return previousExample; } previousExample = entry.getValue(); previous = current; } return previousExample; }  boolean isObfuscable(); boolean isPersistable(); ObfuscationLevelType getObfuscationLevelType(); int getNbOfObfuscationLevelStep(); String getObfuscableDataType(); String getObfuscationExample(double obfuscationLevel); List<String> getAllObfuscationExamples(); List<String> getAllObfuscationExamplesReversed(); List<ObfuscationExample> getObfuscationExamplesReversed(); double computeObfuscationLevel(int obfuscationLevelStep); }
ObfuscatorInfo { public String getObfuscationExample(double obfuscationLevel) { if (null == obfuscationExamples || obfuscationExamples.size() <= 0) { return ""; } int index = 0; double previous = 0.0; String previousExample = ""; for(Entry<Double, String> entry : obfuscationExamples.entrySet()) { double current = entry.getKey().doubleValue(); if (0 == index) { previousExample = entry.getValue(); previous = -50000.0; index++; continue; } if (obfuscationLevel == previous || (obfuscationLevel >= previous && obfuscationLevel < current)) { return previousExample; } previousExample = entry.getValue(); previous = current; } return previousExample; }  boolean isObfuscable(); boolean isPersistable(); ObfuscationLevelType getObfuscationLevelType(); int getNbOfObfuscationLevelStep(); String getObfuscableDataType(); String getObfuscationExample(double obfuscationLevel); List<String> getAllObfuscationExamples(); List<String> getAllObfuscationExamplesReversed(); List<ObfuscationExample> getObfuscationExamplesReversed(); double computeObfuscationLevel(int obfuscationLevelStep);  }