X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fcommon%2Ffixedflex%2FGridUtilsTest.java;h=9ce4b3fac560782504610de75cd1851125286ba7;hb=refs%2Fchanges%2F46%2F100646%2F27;hp=d93051fafa538c20dfa6199e4de15eddb2afaff1;hpb=211dacfed540c8ddbf552c229c74b6054b185720;p=transportpce.git diff --git a/common/src/test/java/org/opendaylight/transportpce/common/fixedflex/GridUtilsTest.java b/common/src/test/java/org/opendaylight/transportpce/common/fixedflex/GridUtilsTest.java index d93051faf..9ce4b3fac 100644 --- a/common/src/test/java/org/opendaylight/transportpce/common/fixedflex/GridUtilsTest.java +++ b/common/src/test/java/org/opendaylight/transportpce/common/fixedflex/GridUtilsTest.java @@ -23,6 +23,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.ty import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.ModulationFormat; import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.available.freq.map.AvailFreqMaps; import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev211210.available.freq.map.AvailFreqMapsKey; +import org.opendaylight.yangtools.yang.common.Decimal64; import org.opendaylight.yangtools.yang.common.Uint32; public class GridUtilsTest { @@ -61,34 +62,34 @@ public class GridUtilsTest { @Test public void getIndexFromFrequencyTest() { - assertEquals("Index should be 693", 693, GridUtils.getIndexFromFrequency(BigDecimal.valueOf(195.65625))); - assertEquals("Index should be 0", 0, GridUtils.getIndexFromFrequency(BigDecimal.valueOf(191.325))); - assertEquals("Index should be 767", 767, GridUtils.getIndexFromFrequency(BigDecimal.valueOf(196.11875))); - assertEquals("Index should be 8", 8, GridUtils.getIndexFromFrequency(BigDecimal.valueOf(191.375))); - assertEquals("Index should be 15", 15, GridUtils.getIndexFromFrequency(BigDecimal.valueOf(191.41875))); - assertEquals("Index should be 768", 768, GridUtils.getIndexFromFrequency(BigDecimal.valueOf(196.125))); + assertEquals("Index should be 693", 693, GridUtils.getIndexFromFrequency(Decimal64.valueOf("195.65625"))); + assertEquals("Index should be 0", 0, GridUtils.getIndexFromFrequency(Decimal64.valueOf("191.325"))); + assertEquals("Index should be 767", 767, GridUtils.getIndexFromFrequency(Decimal64.valueOf("196.11875"))); + assertEquals("Index should be 8", 8, GridUtils.getIndexFromFrequency(Decimal64.valueOf("191.375"))); + assertEquals("Index should be 15", 15, GridUtils.getIndexFromFrequency(Decimal64.valueOf("191.41875"))); + assertEquals("Index should be 768", 768, GridUtils.getIndexFromFrequency(Decimal64.valueOf("196.125"))); } @Test(expected = IllegalArgumentException.class) public void getIndexFromFrequencyExceptionTest() { - GridUtils.getIndexFromFrequency(BigDecimal.valueOf(196.13125)); + GridUtils.getIndexFromFrequency(Decimal64.valueOf("196.13125")); } @Test(expected = IllegalArgumentException.class) public void getIndexFromFrequencyException2Test() { - GridUtils.getIndexFromFrequency(BigDecimal.valueOf(191.31875)); + GridUtils.getIndexFromFrequency(Decimal64.valueOf("191.31875")); } @Test public void getWidthFromRateAndModulationFormatTest() { - assertEquals("Width should be 75", new FrequencyGHz(GridConstant.WIDTH_75), + assertEquals("Width should be 75", new FrequencyGHz(Decimal64.valueOf(GridConstant.WIDTH_75)), GridUtils.getWidthFromRateAndModulationFormat(ServiceRateConstant.RATE_400, ModulationFormat.DpQam16)); } @Test public void getWidthFromRateAndModulationFormatNotFoundTest() { - assertEquals("As not found width should be 40", new FrequencyGHz(GridConstant.WIDTH_40), + assertEquals("As not found width should be 40", new FrequencyGHz(Decimal64.valueOf(GridConstant.WIDTH_40)), GridUtils.getWidthFromRateAndModulationFormat(ServiceRateConstant.RATE_100, ModulationFormat.DpQam16)); } @@ -96,7 +97,7 @@ public class GridUtilsTest { @Test public void getCentralFrequencyTest() { assertEquals("Central frequency should be 191.350", - new FrequencyTHz(BigDecimal.valueOf(191.35).setScale(3)), + new FrequencyTHz(Decimal64.valueOf(BigDecimal.valueOf(191.35).setScale(3))), GridUtils.getCentralFrequency(BigDecimal.valueOf(191.325), BigDecimal.valueOf(191.375))); } @@ -104,7 +105,7 @@ public class GridUtilsTest { public void getCentralFrequencyWithPrecisionTest() { assertEquals("Central frequency should be 191.3500", new org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.FrequencyTHz( - BigDecimal.valueOf(191.35).setScale(4)), + Decimal64.valueOf(BigDecimal.valueOf(191.35).setScale(4))), GridUtils.getCentralFrequencyWithPrecision(BigDecimal.valueOf(191.325), BigDecimal.valueOf(191.375), 4)); } @@ -113,7 +114,7 @@ public class GridUtilsTest { public void getCentralFrequencyWithPrecisionAndRoundTest() { assertEquals("Central frequency should be 191.3499", new org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.FrequencyTHz( - BigDecimal.valueOf(191.3499)), + Decimal64.valueOf("191.3499")), GridUtils.getCentralFrequencyWithPrecision(BigDecimal.valueOf(191.3244445), BigDecimal.valueOf(191.3754457788), 4)); } @@ -123,15 +124,15 @@ public class GridUtilsTest { ServicePathInput input = new ServicePathInputBuilder() .setWaveNumber(Uint32.valueOf(1)) .setCenterFreq(new org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019 - .FrequencyTHz(BigDecimal.valueOf(196.1))) + .FrequencyTHz(Decimal64.valueOf("196.1"))) .setHigherSpectralSlotNumber(Uint32.valueOf(768)) .setLowerSpectralSlotNumber(Uint32.valueOf(761)) .setMaxFreq(new org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019 - .FrequencyTHz(BigDecimal.valueOf(196.125))) + .FrequencyTHz(Decimal64.valueOf("196.125"))) .setMinFreq(new org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019 - .FrequencyTHz(BigDecimal.valueOf(196.075))) + .FrequencyTHz(Decimal64.valueOf("196.075"))) .setNmcWidth(new org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019 - .FrequencyGHz(GridConstant.WIDTH_40)) + .FrequencyGHz(Decimal64.valueOf(GridConstant.WIDTH_40))) .build(); SpectrumInformation spectrumInformation = GridUtils.initSpectrumInformationFromServicePathInput(input); assertEquals("Width should be 40", BigDecimal.valueOf(40), spectrumInformation.getWidth()); @@ -153,11 +154,11 @@ public class GridUtilsTest { .setHigherSpectralSlotNumber(Uint32.valueOf(768)) .setLowerSpectralSlotNumber(Uint32.valueOf(761)) .setMaxFreq(new org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019 - .FrequencyTHz(BigDecimal.valueOf(196.125))) + .FrequencyTHz(Decimal64.valueOf("196.125"))) .setMinFreq(new org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019 - .FrequencyTHz(BigDecimal.valueOf(196.075))) + .FrequencyTHz(Decimal64.valueOf("196.075"))) .setNmcWidth(new org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019 - .FrequencyGHz(GridConstant.WIDTH_40)) + .FrequencyGHz(Decimal64.valueOf(GridConstant.WIDTH_40))) .build(); SpectrumInformation spectrumInformation = GridUtils.initSpectrumInformationFromServicePathInput(input); assertEquals("Width should be 40", BigDecimal.valueOf(40), spectrumInformation.getWidth()); @@ -179,7 +180,7 @@ public class GridUtilsTest { .setHigherSpectralSlotNumber(Uint32.valueOf(768)) .setLowerSpectralSlotNumber(Uint32.valueOf(761)) .setNmcWidth(new org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019 - .FrequencyGHz(GridConstant.WIDTH_40)) + .FrequencyGHz(Decimal64.valueOf(GridConstant.WIDTH_40))) .build(); SpectrumInformation spectrumInformation = GridUtils.initSpectrumInformationFromServicePathInput(input); assertEquals("Width should be 40", BigDecimal.valueOf(40), spectrumInformation.getWidth());