IntegerQuantizer { public static Quantizer<Integer> withCompressionFactor(int compressionFactor) { return new CompressingQuantizer(compressionFactor); } IntegerQuantizer(); static Quantizer<Integer> withCompressionFactor(int compressionFactor);  }
@Test public void testWithCompressionFactor_5() throws Exception { Quantizer<Integer> quantizer = IntegerQuantizer.withCompressionFactor(5); Assert.assertEquals("0", quantizer.getQuantizedValue(0).toString()); Assert.assertEquals("0", quantizer.getQuantizedValue(4).toString()); Assert.assertEquals("5", quantizer.getQuantizedValue(5).toString()); Assert.assertEquals("5", quantizer.getQuantizedValue(9).toString()); Assert.assertEquals("10", quantizer.getQuantizedValue(11).toString()); Assert.assertEquals("0", quantizer.getQuantizedValue(-0).toString()); Assert.assertEquals("0", quantizer.getQuantizedValue(-4).toString()); Assert.assertEquals("-5", quantizer.getQuantizedValue(-5).toString()); Assert.assertEquals("-5", quantizer.getQuantizedValue(-9).toString()); Assert.assertEquals("-10", quantizer.getQuantizedValue(-11).toString()); }
@Test(expected = IllegalArgumentException.class) public void testWithCompressionFactor_1() throws Exception { IntegerQuantizer.withCompressionFactor(1); }