use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class PortablePositionFactoryTest method createSinglePortablePosition.
@Test
public void createSinglePortablePosition() {
// GIVEN
FieldDefinition fd = new FieldDefinitionImpl(1, "field", FieldType.PORTABLE, 0);
int streamPosition = 100;
int factoryId = 123, classId = 546;
boolean nil = false, leaf = true;
// WHEN
PortablePosition p = PortablePositionFactory.createSinglePortablePosition(fd, streamPosition, factoryId, classId, nil, leaf);
// THEN
assertFalse(p.isNull());
assertFalse(p.isEmpty());
assertFalse(p.isNullOrEmpty());
assertEquals(nil, p.isNull());
assertEquals(leaf, p.isLeaf());
assertFalse(p.isAny());
assertEquals(fd.getType(), p.getType());
assertEquals(-1, p.getLen());
assertEquals(classId, p.getClassId());
assertEquals(factoryId, p.getFactoryId());
assertEquals(-1, p.getIndex());
assertEquals(streamPosition, p.getStreamPosition());
assertFalse(p.isMultiPosition());
assertAsMultiPositionThrowsException(p);
}
use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class PortablePositionFactoryTest method createSinglePrimitivePosition.
@Test
public void createSinglePrimitivePosition() {
// GIVEN
FieldDefinition fd = new FieldDefinitionImpl(1, "field", FieldType.PORTABLE, 0);
int streamPosition = 100;
int index = 1;
boolean leaf = true;
// WHEN
PortablePosition p = PortablePositionFactory.createSinglePrimitivePosition(fd, streamPosition, index, leaf);
// THEN
assertFalse(p.isNull());
assertFalse(p.isEmpty());
assertFalse(p.isNullOrEmpty());
assertEquals(leaf, p.isLeaf());
assertFalse(p.isAny());
assertEquals(fd.getType(), p.getType());
assertEquals(-1, p.getLen());
assertEquals(-1, p.getClassId());
assertEquals(-1, p.getFactoryId());
assertEquals(index, p.getIndex());
assertEquals(streamPosition, p.getStreamPosition());
assertFalse(p.isMultiPosition());
assertAsMultiPositionThrowsException(p);
}
use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class PortablePositionFactoryTest method createSinglePortablePosition_withIndex_nullifiedDueIndexOutOfBound.
@Test
public void createSinglePortablePosition_withIndex_nullifiedDueIndexOutOfBound() {
// GIVEN
FieldDefinition fd = new FieldDefinitionImpl(1, "field", FieldType.PORTABLE, 0);
int streamPosition = 100;
int factoryId = 123, classId = 546;
int index = 1, len = 0;
boolean leaf = true;
// WHEN
PortablePosition p = PortablePositionFactory.createSinglePortablePosition(fd, streamPosition, factoryId, classId, index, len, leaf);
// THEN
// nullified!
assertTrue(p.isNull());
}
use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class PortableUtilsTest method validateFactoryAndClass_incompatibleFactoryId.
@Test
public void validateFactoryAndClass_incompatibleFactoryId() {
// GIVEN
int factoryId = 1;
int classId = 2;
FieldDefinition fd = mock(FieldDefinition.class);
// WHEN ids are compatible
when(fd.getFactoryId()).thenReturn(factoryId + 1);
when(fd.getClassId()).thenReturn(classId);
// THEN - ex thrown
expected.expect(IllegalArgumentException.class);
PortableUtils.validateFactoryAndClass(fd, factoryId, classId, "person.brain");
}
use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class PortableUtilsTest method validateArrayType_notArray.
@Test
public void validateArrayType_notArray() {
// GIVEN
ClassDefinition cd = mock(ClassDefinition.class);
FieldDefinition fd = mock(FieldDefinition.class);
// WHEN
when(fd.getType()).thenReturn(FieldType.BOOLEAN);
// THEN - ex thrown
expected.expect(IllegalArgumentException.class);
PortableUtils.validateArrayType(cd, fd, "person.brain");
}
Aggregations