use of com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField in project java-chassis by ServiceComb.
the class AbstractFieldCodec method initFieldMap.
private void initFieldMap(ProtobufSchema schema, Type[] types) {
Iterator<ProtobufField> fieldIter = schema.getRootType().fields().iterator();
for (int idx = 0; idx < schema.getRootType().getFieldCount(); idx++) {
JavaType type = TypeFactory.defaultInstance().constructType(types[idx]);
ProtobufField field = fieldIter.next();
ReaderHelpData helpData = new ReaderHelpData();
helpData.index = idx;
helpData.deser = ((CseObjectReader) reader).findDeserializer(type);
readerHelpDataMap.put(field.name, helpData);
}
}
use of com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField in project java-chassis by ServiceComb.
the class TestAbstractFieldCodec method testInit.
@Test
public void testInit() {
ProtobufField[] protobufFieldArray = new ProtobufField[5];
FieldElement rawType = null;
FieldType type = FieldType.STRING;
ProtobufField p = new ProtobufField(rawType, type);
protobufFieldArray[0] = p;
Type[] types = new Type[1];
types[0] = Integer.TYPE;
Mockito.when(schema.getRootType()).thenReturn(Mockito.mock(ProtobufMessage.class));
Mockito.when(schema.getRootType().getFieldCount()).thenReturn(1);
Mockito.when(schema.getRootType().fields()).thenReturn(Arrays.asList(protobufFieldArray));
abstractFieldCodec.init(schema, types);
Assert.assertNotNull(abstractFieldCodec.readerHelpDataMap.get("UNKNOWN"));
}
use of com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField in project java-chassis by ServiceComb.
the class TestParamFieldCodec method testInit.
@Test
public void testInit() {
Assert.assertNotNull(paramFieldCodec);
ProtobufField[] protobufFieldArray = new ProtobufField[5];
FieldElement rawType = null;
FieldType type = FieldType.STRING;
ProtobufField p = new ProtobufField(rawType, type);
protobufFieldArray[0] = p;
Type[] types = new Type[10];
types[0] = Integer.TYPE;
Mockito.when(schema.getRootType()).thenReturn(Mockito.mock(ProtobufMessage.class));
Mockito.when(schema.getRootType().getFieldCount()).thenReturn(1);
Mockito.when(schema.getRootType().fields()).thenReturn(Arrays.asList(protobufFieldArray));
Assert.assertNull(paramFieldCodec.reader);
Assert.assertNull(paramFieldCodec.writer);
paramFieldCodec.init(schema, types);
Assert.assertNotNull(paramFieldCodec.reader);
Assert.assertNotNull(paramFieldCodec.writer);
}
use of com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField in project java-chassis by ServiceComb.
the class TestResultFieldCodec method testInit.
@Test
public void testInit() {
Assert.assertNotNull(resultFieldCodec);
ProtobufField[] protobufFieldArray = new ProtobufField[5];
FieldElement rawType = null;
FieldType type = FieldType.STRING;
ProtobufField p = new ProtobufField(rawType, type);
protobufFieldArray[0] = p;
Type[] types = new Type[10];
types[0] = Integer.TYPE;
Mockito.when(schema.getRootType()).thenReturn(Mockito.mock(ProtobufMessage.class));
Mockito.when(schema.getRootType().getFieldCount()).thenReturn(1);
Mockito.when(schema.getRootType().fields()).thenReturn(Arrays.asList(protobufFieldArray));
Assert.assertNull(resultFieldCodec.reader);
Assert.assertNull(resultFieldCodec.writer);
resultFieldCodec.init(schema, types);
Assert.assertNotNull(resultFieldCodec.reader);
Assert.assertNotNull(resultFieldCodec.writer);
}
use of com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField in project java-chassis by ServiceComb.
the class TestStandardParamCodec method testInit.
@Test
public void testInit() {
Assert.assertNotNull(standardParamCodec);
ProtobufField[] protobufFieldArray = new ProtobufField[5];
FieldElement rawType = null;
FieldType type = FieldType.STRING;
ProtobufField p = new ProtobufField(rawType, type);
protobufFieldArray[0] = p;
Type[] types = new Type[1];
types[0] = Integer.TYPE;
Mockito.when(schema.getSchemaType()).thenReturn(FORMAT_NAME_PROTOBUF);
Mockito.when(schema.getRootType()).thenReturn(Mockito.mock(ProtobufMessage.class));
Mockito.when(schema.getRootType().getFieldCount()).thenReturn(1);
Mockito.when(schema.getRootType().fields()).thenReturn(Arrays.asList(protobufFieldArray));
Assert.assertNull(standardParamCodec.writer);
Assert.assertNull(standardParamCodec.reader);
standardParamCodec.init(schema, types);
Assert.assertNotNull(standardParamCodec.writer);
Assert.assertNotNull(standardParamCodec.reader);
}
Aggregations