### Question:
NormalizedCentralityResult extends CentralityResult { public double score(int nodeId) { return normalizationFunction.applyAsDouble(result.score(nodeId)); } NormalizedCentralityResult(CentralityResult result, DoubleUnaryOperator normalizationFunction); void export(String propertyName, NodePropertyExporter exporter, DoubleUnaryOperator normalizationFunction); double score(int nodeId); double score(long nodeId); void export(String propertyName, NodePropertyExporter exporter);  }### Answer:
@Test void maxNormalization() { CentralityResultWithStatistics centralityResult = mock(CentralityResultWithStatistics.class); when(centralityResult.score(0)).thenReturn(1.0); when(centralityResult.score(1)).thenReturn(2.0); when(centralityResult.score(2)).thenReturn(3.0); when(centralityResult.score(3)).thenReturn(4.0); when(centralityResult.computeMax()).thenReturn(4.0); CentralityResult normalizedResult = NormalizationFunction.MAX.apply(centralityResult); assertEquals(0.25, normalizedResult.score(0), 0.01); assertEquals(0.5, normalizedResult.score(1), 0.01); assertEquals(0.75, normalizedResult.score(2), 0.01); assertEquals(1.0, normalizedResult.score(3), 0.01); }
@Test void noNormalization() { CentralityResultWithStatistics centralityResult = mock(CentralityResultWithStatistics.class); when(centralityResult.score(0)).thenReturn(1.0); when(centralityResult.score(1)).thenReturn(2.0); when(centralityResult.score(2)).thenReturn(3.0); when(centralityResult.score(3)).thenReturn(4.0); when(centralityResult.computeMax()).thenReturn(4.0); CentralityResult normalizedResult = NormalizationFunction.NONE.apply(centralityResult); assertEquals(1.0, normalizedResult.score(0), 0.01); assertEquals(2.0, normalizedResult.score(1), 0.01); assertEquals(3.0, normalizedResult.score(2), 0.01); assertEquals(4.0, normalizedResult.score(3), 0.01); }
@Test void l2Norm() { CentralityResultWithStatistics centralityResult = mock(CentralityResultWithStatistics.class); when(centralityResult.score(0)).thenReturn(1.0); when(centralityResult.score(1)).thenReturn(2.0); when(centralityResult.score(2)).thenReturn(3.0); when(centralityResult.score(3)).thenReturn(4.0); when(centralityResult.computeL2Norm()).thenReturn(4.0); CentralityResult normalizedResult = NormalizationFunction.L2NORM.apply(centralityResult); assertEquals(0.25, normalizedResult.score(0), 0.01); assertEquals(0.5, normalizedResult.score(1), 0.01); assertEquals(0.75, normalizedResult.score(2), 0.01); assertEquals(1.0, normalizedResult.score(3), 0.01); }
@Test void l1Norm() { CentralityResultWithStatistics centralityResult = mock(CentralityResultWithStatistics.class); when(centralityResult.score(0)).thenReturn(1.0); when(centralityResult.score(1)).thenReturn(2.0); when(centralityResult.score(2)).thenReturn(3.0); when(centralityResult.score(3)).thenReturn(4.0); when(centralityResult.computeL1Norm()).thenReturn(4.0); CentralityResult normalizedResult = NormalizationFunction.L1NORM.apply(centralityResult); assertEquals(0.25, normalizedResult.score(0), 0.01); assertEquals(0.5, normalizedResult.score(1), 0.01); assertEquals(0.75, normalizedResult.score(2), 0.01); assertEquals(1.0, normalizedResult.score(3), 0.01); }