/** {@inheritDoc} */ @Override public boolean isEnum() { return target().isEnum(); }
@Override public void examine(IgniteCache cache) { BinaryObject bo = (BinaryObject) cache.get(2); BinaryType type = bo.type(); assertFalse(bo.type().isEnum()); assertEquals(DYNAMIC_TYPE_NAME, type.typeName()); Collection<String> fieldNames = type.fieldNames(); assertEquals(2, fieldNames.size()); assertTrue(fieldNames.contains(DYNAMIC_INT_FIELD_NAME)); assertTrue(fieldNames.contains(DYNAMIC_STR_FIELD_NAME)); } };
@Override public void examine(IgniteCache cache) { BinaryObject bo = (BinaryObject) cache.get(2); BinaryType type = bo.type(); assertFalse(type.isEnum()); assertEquals(DYNAMIC_TYPE_NAME, type.typeName()); Collection<String> fieldNames = type.fieldNames(); assertEquals(1, fieldNames.size()); assertTrue(fieldNames.contains(DYNAMIC_INT_FIELD_NAME)); assertEquals(DYNAMIC_INT_FIELD_NAME, type.affinityKeyFieldName()); } };
@Override public void examine(IgniteCache cache) { BinaryObject enumBo = (BinaryObject) cache.get(4); assertEquals(EnumType.ENUM_VAL_0.ordinal(), enumBo.enumOrdinal()); BinaryType type = enumBo.type(); assertTrue(type.isEnum()); assertEquals(EnumType.class.getName(), type.typeName()); Collection<BinaryObject> enumVals = type.enumValues(); assertEquals(2, enumVals.size()); int i = 0; for (BinaryObject bo : enumVals) { assertEquals(i, bo.enumOrdinal()); assertEquals("ENUM_VAL_" + (i++), bo.enumName()); } } };
/** */ private void assertBinaryObjectsEqual(BinaryObject exp, BinaryObject actual) throws Exception { assertBinaryTypesEqual(exp.type(), actual.type()); for (String f : exp.type().fieldNames()) { Object expVal = exp.field(f); Class<?> cls = expVal.getClass(); if (cls.getMethod("equals", Object.class).getDeclaringClass() == cls) assertEquals(expVal, actual.field(f)); } if (exp.type().isEnum()) assertEquals(exp.enumOrdinal(), actual.enumOrdinal()); }
if (meta.isEnum()) { try { return obj.deserialize().toString();
/** */ private void assertBinaryObjectsEqual(BinaryObject exp, BinaryObject actual) throws Exception { assertBinaryTypesEqual(exp.type(), actual.type()); for (String f : exp.type().fieldNames()) { Object expVal = exp.field(f); Class<?> cls = expVal.getClass(); if (cls.getMethod("equals", Object.class).getDeclaringClass() == cls) assertEquals(expVal, actual.field(f)); } if (exp.type().isEnum()) assertEquals(exp.enumOrdinal(), actual.enumOrdinal()); } }
/** */ private void assertBinaryTypesEqual(BinaryType exp, BinaryType actual) { assertEquals(exp.typeId(), actual.typeId()); assertEquals(exp.typeName(), actual.typeName()); assertArrayEquals(exp.fieldNames().toArray(), actual.fieldNames().toArray()); for (String f : exp.fieldNames()) assertEquals(exp.fieldTypeName(f), actual.fieldTypeName(f)); assertEquals(exp.affinityKeyFieldName(), actual.affinityKeyFieldName()); assertEquals(exp.isEnum(), actual.isEnum()); }
/** * Check ability to resolve typeId from class name. * * @throws Exception If failed. */ @Test public void testZeroTypeId() throws Exception { startUp(true); final BinaryContext ctx = ((CacheObjectBinaryProcessorImpl)((IgniteEx)node1).context().cacheObjects()).binaryContext(); final BinaryObject enumObj = new BinaryEnumObjectImpl(ctx, 0, EnumType.class.getName(), EnumType.ONE.ordinal()); assert enumObj.type().isEnum(); }
/** * Validate single value. * * @param obj Binary value. * @param val Expected value. */ private void validate(BinaryObject obj, DeclaredBodyEnum val) { assertTrue(obj.type().isEnum()); assertEquals(node1.binary().typeId(DeclaredBodyEnum.class.getName()), obj.type().typeId()); assertEquals(node2.binary().typeId(DeclaredBodyEnum.class.getName()), obj.type().typeId()); assertEquals(val.ordinal(), obj.enumOrdinal()); }
/** */ private void assertBinaryTypesEqual(BinaryType exp, BinaryType actual) { assertEquals(exp.typeId(), actual.typeId()); assertEquals(exp.typeName(), actual.typeName()); assertEquals(exp.fieldNames(), actual.fieldNames()); for (String f : exp.fieldNames()) assertEquals(exp.fieldTypeName(f), actual.fieldTypeName(f)); assertEquals(exp.affinityKeyFieldName(), actual.affinityKeyFieldName()); assertEquals(exp.isEnum(), actual.isEnum()); }
/** * Validate single value. * * @param obj Binary value. * @param val Expected value. */ private void validate(BinaryObject obj, EnumType val) { assertTrue(obj.type().isEnum()); assertEquals(node1.binary().typeId(EnumType.class.getName()), obj.type().typeId()); assertEquals(node2.binary().typeId(EnumType.class.getName()), obj.type().typeId()); assertEquals(val.ordinal(), obj.enumOrdinal()); if (register) assertEquals(val.name(), obj.enumName()); }
/** * @param cache Cache. * @param key Key. * @param expVal Expected value. */ private static void assertBinaryEnum(IgniteCache<Object, Object> cache, int key, TestEnum expVal) { Marshaller marsh = ((IgniteCacheProxy)cache).context().marshaller(); if (marsh instanceof BinaryMarshaller) { BinaryObject enumObj = (BinaryObject)cache.withKeepBinary().get(key); assertEquals(expVal.ordinal(), enumObj.enumOrdinal()); assertTrue(enumObj.type().isEnum()); assertTrue(enumObj instanceof BinaryEnumObjectImpl); } }
/** {@inheritDoc} */ @Override public boolean isEnum() { return target().isEnum(); }
if (meta.isEnum()) { try { return obj.deserialize().toString();