Search in sources :

Example 1 with FieldElement

use of com.fasterxml.jackson.dataformat.protobuf.protoparser.protoparser.FieldElement 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"));
}
Also used : ProtobufMessage(com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufMessage) FieldType(com.fasterxml.jackson.dataformat.protobuf.schema.FieldType) Type(java.lang.reflect.Type) FieldElement(com.fasterxml.jackson.dataformat.protobuf.protoparser.protoparser.FieldElement) ProtobufField(com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField) FieldType(com.fasterxml.jackson.dataformat.protobuf.schema.FieldType) Test(org.junit.Test)

Example 2 with FieldElement

use of com.fasterxml.jackson.dataformat.protobuf.protoparser.protoparser.FieldElement 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);
}
Also used : ProtobufMessage(com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufMessage) FieldType(com.fasterxml.jackson.dataformat.protobuf.schema.FieldType) Type(java.lang.reflect.Type) FieldElement(com.fasterxml.jackson.dataformat.protobuf.protoparser.protoparser.FieldElement) ProtobufField(com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField) FieldType(com.fasterxml.jackson.dataformat.protobuf.schema.FieldType) Test(org.junit.Test)

Example 3 with FieldElement

use of com.fasterxml.jackson.dataformat.protobuf.protoparser.protoparser.FieldElement 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);
}
Also used : ProtobufMessage(com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufMessage) FieldType(com.fasterxml.jackson.dataformat.protobuf.schema.FieldType) Type(java.lang.reflect.Type) FieldElement(com.fasterxml.jackson.dataformat.protobuf.protoparser.protoparser.FieldElement) ProtobufField(com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField) FieldType(com.fasterxml.jackson.dataformat.protobuf.schema.FieldType) Test(org.junit.Test)

Example 4 with FieldElement

use of com.fasterxml.jackson.dataformat.protobuf.protoparser.protoparser.FieldElement 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);
}
Also used : ProtobufMessage(com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufMessage) FieldType(com.fasterxml.jackson.dataformat.protobuf.schema.FieldType) Type(java.lang.reflect.Type) FieldElement(com.fasterxml.jackson.dataformat.protobuf.protoparser.protoparser.FieldElement) ProtobufField(com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField) FieldType(com.fasterxml.jackson.dataformat.protobuf.schema.FieldType) Test(org.junit.Test)

Example 5 with FieldElement

use of com.fasterxml.jackson.dataformat.protobuf.protoparser.protoparser.FieldElement in project java-chassis by ServiceComb.

the class TestStandardResultCodec method testInit.

@Test
public void testInit() {
    Assert.assertNotNull(standardResultCodec);
    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(standardResultCodec.reader);
    Assert.assertNull(standardResultCodec.writer);
    standardResultCodec.init(schema, types);
    Assert.assertNotNull(standardResultCodec.reader);
    Assert.assertNotNull(standardResultCodec.writer);
}
Also used : ProtobufMessage(com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufMessage) FieldType(com.fasterxml.jackson.dataformat.protobuf.schema.FieldType) Type(java.lang.reflect.Type) FieldElement(com.fasterxml.jackson.dataformat.protobuf.protoparser.protoparser.FieldElement) ProtobufField(com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField) FieldType(com.fasterxml.jackson.dataformat.protobuf.schema.FieldType) Test(org.junit.Test)

Aggregations

FieldElement (com.fasterxml.jackson.dataformat.protobuf.protoparser.protoparser.FieldElement)5 FieldType (com.fasterxml.jackson.dataformat.protobuf.schema.FieldType)5 ProtobufField (com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufField)5 ProtobufMessage (com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufMessage)5 Type (java.lang.reflect.Type)5 Test (org.junit.Test)5