Search in sources :

Example 36 with TypicalData

use of protos.TypicalData in project j2objc by google.

the class CompatibilityTest method testMergeFromOtherMessage.

public void testMergeFromOtherMessage() throws Exception {
    TypicalData data = TypicalData.newBuilder().setMyInt(123).build();
    Message dataAsMsg = data;
    TypicalData.Builder builder1 = TypicalData.newBuilder().mergeFrom(dataAsMsg);
    TypicalData.Builder builder2 = TypicalData.newBuilder().mergeFrom(data);
    assertEquals(123, builder1.getMyInt());
    assertEquals(123, builder2.getMyInt());
}
Also used : TypicalData(protos.TypicalData) GeneratedMessage(com.google.protobuf.GeneratedMessage) TypicalDataMessage(protos.TypicalDataMessage) Message(com.google.protobuf.Message)

Example 37 with TypicalData

use of protos.TypicalData in project j2objc by google.

the class CompatibilityTest method testIsEqualAndHashCode.

public void testIsEqualAndHashCode() throws Exception {
    TypicalDataMessage subMsg1 = TypicalDataMessage.newBuilder().setMyMessageInt(11).build();
    TypicalData.Builder builder1 = TypicalData.newBuilder().setMyMessage(subMsg1).setMyInt(22);
    TypicalData data1 = builder1.build();
    TypicalDataMessage subMsg2 = TypicalDataMessage.newBuilder().setMyMessageInt(11).build();
    TypicalData.Builder builder2 = TypicalData.newBuilder().setMyMessage(subMsg2).setMyInt(22);
    TypicalData data2 = builder2.build();
    TypicalDataMessage subMsg3 = TypicalDataMessage.newBuilder().setMyMessageInt(33).build();
    TypicalData.Builder builder3 = TypicalData.newBuilder().setMyMessage(subMsg3).setMyInt(22);
    TypicalData data3 = builder3.build();
    // Builders are not equal.
    assertFalse(builder1.equals(builder2));
    assertFalse(builder2.equals(builder1));
    assertTrue(data1.equals(data2));
    assertTrue(data2.equals(data1));
    assertEquals(data1.hashCode(), data2.hashCode());
    assertFalse(data1.equals(data3));
    assertFalse(data3.equals(data1));
}
Also used : TypicalDataMessage(protos.TypicalDataMessage) TypicalData(protos.TypicalData)

Example 38 with TypicalData

use of protos.TypicalData in project j2objc by google.

the class CompatibilityTest method testSetAndGetRepeatedTypicalData.

public void testSetAndGetRepeatedTypicalData() throws Exception {
    TypicalData data = TypicalData.newBuilder().setMyInt(42).build();
    TypicalDataSet dataset = TypicalDataSet.newBuilder().addRepeatedTypicalData(data).build();
    assertEquals(1, dataset.getRepeatedTypicalDataCount());
    assertEquals(42, dataset.getRepeatedTypicalData(0).getMyInt());
}
Also used : TypicalDataSet(protos.TypicalDataSet) TypicalData(protos.TypicalData)

Example 39 with TypicalData

use of protos.TypicalData in project j2objc by google.

the class CompatibilityTest method testToBuilder.

public void testToBuilder() throws Exception {
    TypicalData data = TypicalData.newBuilder().setMyInt(42).setMyMessage(TypicalDataMessage.newBuilder().setMyMessageInt(43)).build();
    TypicalData.Builder builder = data.toBuilder();
    TypicalDataMessage message = builder.getMyMessage();
    assertNotNull(message);
    assertEquals(43, message.getMyMessageInt());
}
Also used : TypicalDataMessage(protos.TypicalDataMessage) TypicalData(protos.TypicalData)

Aggregations

TypicalData (protos.TypicalData)39 ByteArrayInputStream (java.io.ByteArrayInputStream)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 TypicalDataMessage (protos.TypicalDataMessage)5 ByteString (com.google.protobuf.ByteString)3 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)3 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)3 ArrayList (java.util.ArrayList)3 MessageLite (com.google.protobuf.MessageLite)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 Descriptor (com.google.protobuf.Descriptors.Descriptor)1 EnumDescriptor (com.google.protobuf.Descriptors.EnumDescriptor)1 EnumValueDescriptor (com.google.protobuf.Descriptors.EnumValueDescriptor)1 ExtensionRegistry (com.google.protobuf.ExtensionRegistry)1 ExtensionRegistryLite (com.google.protobuf.ExtensionRegistryLite)1 GeneratedMessage (com.google.protobuf.GeneratedMessage)1 ExtendableMessageOrBuilder (com.google.protobuf.GeneratedMessage.ExtendableMessageOrBuilder)1 Message (com.google.protobuf.Message)1 ProtocolMessageEnum (com.google.protobuf.ProtocolMessageEnum)1