Java源码示例:org.apache.flink.graph.drivers.transform.GraphKeyTypeTransform.LongValueToUnsignedInt
示例1
@Test
public void testToInt() throws Exception {
TranslateFunction<LongValue, Integer> translator = new LongValueToUnsignedInt();
Assert.assertEquals(Integer.valueOf(0),
translator.translate(new LongValue(0L), null));
Assert.assertEquals(Integer.valueOf(Integer.MIN_VALUE),
translator.translate(new LongValue((long) Integer.MAX_VALUE + 1), null));
Assert.assertEquals(Integer.valueOf(-1),
translator.translate(new LongValue(LongValueToUnsignedInt.MAX_VERTEX_COUNT - 1), null));
}
示例2
@Test
public void testFromInt() throws Exception {
TranslateFunction<Integer, LongValueWithProperHashCode> translator = new UnsignedIntToLongValueWithProperHashCode();
Assert.assertEquals(new LongValueWithProperHashCode(0L),
translator.translate(0, longValueWithProperHashCode));
Assert.assertEquals(new LongValueWithProperHashCode((long) Integer.MAX_VALUE + 1),
translator.translate(Integer.MIN_VALUE, longValueWithProperHashCode));
Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedInt.MAX_VERTEX_COUNT - 1),
translator.translate(-1, longValueWithProperHashCode));
}
示例3
@Test
public void testToInt() throws Exception {
TranslateFunction<LongValue, Integer> translator = new LongValueToUnsignedInt();
Assert.assertEquals(Integer.valueOf(0),
translator.translate(new LongValue(0L), null));
Assert.assertEquals(Integer.valueOf(Integer.MIN_VALUE),
translator.translate(new LongValue((long) Integer.MAX_VALUE + 1), null));
Assert.assertEquals(Integer.valueOf(-1),
translator.translate(new LongValue(LongValueToUnsignedInt.MAX_VERTEX_COUNT - 1), null));
}
示例4
@Test
public void testFromInt() throws Exception {
TranslateFunction<Integer, LongValueWithProperHashCode> translator = new UnsignedIntToLongValueWithProperHashCode();
Assert.assertEquals(new LongValueWithProperHashCode(0L),
translator.translate(0, longValueWithProperHashCode));
Assert.assertEquals(new LongValueWithProperHashCode((long) Integer.MAX_VALUE + 1),
translator.translate(Integer.MIN_VALUE, longValueWithProperHashCode));
Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedInt.MAX_VERTEX_COUNT - 1),
translator.translate(-1, longValueWithProperHashCode));
}
示例5
@Test
public void testToInt() throws Exception {
TranslateFunction<LongValue, Integer> translator = new LongValueToUnsignedInt();
Assert.assertEquals(Integer.valueOf(0),
translator.translate(new LongValue(0L), null));
Assert.assertEquals(Integer.valueOf(Integer.MIN_VALUE),
translator.translate(new LongValue((long) Integer.MAX_VALUE + 1), null));
Assert.assertEquals(Integer.valueOf(-1),
translator.translate(new LongValue(LongValueToUnsignedInt.MAX_VERTEX_COUNT - 1), null));
}
示例6
@Test
public void testFromInt() throws Exception {
TranslateFunction<Integer, LongValueWithProperHashCode> translator = new UnsignedIntToLongValueWithProperHashCode();
Assert.assertEquals(new LongValueWithProperHashCode(0L),
translator.translate(0, longValueWithProperHashCode));
Assert.assertEquals(new LongValueWithProperHashCode((long) Integer.MAX_VALUE + 1),
translator.translate(Integer.MIN_VALUE, longValueWithProperHashCode));
Assert.assertEquals(new LongValueWithProperHashCode(LongValueToUnsignedInt.MAX_VERTEX_COUNT - 1),
translator.translate(-1, longValueWithProperHashCode));
}
示例7
@Test(expected = IllegalArgumentException.class)
public void testToIntUpperOutOfRange() throws Exception {
new LongValueToUnsignedInt().translate(new LongValue(LongValueToUnsignedInt.MAX_VERTEX_COUNT), null);
}
示例8
@Test(expected = IllegalArgumentException.class)
public void testToIntLowerOutOfRange() throws Exception {
new LongValueToUnsignedInt().translate(new LongValue(-1), null);
}
示例9
@Test(expected = IllegalArgumentException.class)
public void testToIntUpperOutOfRange() throws Exception {
new LongValueToUnsignedInt().translate(new LongValue(LongValueToUnsignedInt.MAX_VERTEX_COUNT), null);
}
示例10
@Test(expected = IllegalArgumentException.class)
public void testToIntLowerOutOfRange() throws Exception {
new LongValueToUnsignedInt().translate(new LongValue(-1), null);
}
示例11
@Test(expected = IllegalArgumentException.class)
public void testToIntUpperOutOfRange() throws Exception {
new LongValueToUnsignedInt().translate(new LongValue(LongValueToUnsignedInt.MAX_VERTEX_COUNT), null);
}
示例12
@Test(expected = IllegalArgumentException.class)
public void testToIntLowerOutOfRange() throws Exception {
new LongValueToUnsignedInt().translate(new LongValue(-1), null);
}