use of com.hazelcast.jet.protobuf.Messages.Person in project hazelcast by hazelcast.
the class JobSerializerTest method when_serializerIsNotRegistered_then_throwsException.
@Test
public void when_serializerIsNotRegistered_then_throwsException() {
String listName = "list-1";
List<Person> list = client().getList(listName);
list.add(Person.newBuilder().setName("Joe").setAge(33).build());
Pipeline pipeline = Pipeline.create();
pipeline.readFrom(Sources.<Person>list(listName)).map(Person::getName).writeTo(Sinks.logger());
assertThatThrownBy(() -> client().getJet().newJob(pipeline, new JobConfig()).join()).hasCauseInstanceOf(JetException.class);
}
use of com.hazelcast.jet.protobuf.Messages.Person in project hazelcast by hazelcast.
the class JobSerializerTest method when_serializerIsRegisteredForDistributedJob_then_itIsAvailableForAllStages.
@Test
public void when_serializerIsRegisteredForDistributedJob_then_itIsAvailableForAllStages() {
List<String> input = IntStream.range(0, 10_000).boxed().map(t -> Integer.toString(t)).collect(toList());
Pipeline pipeline = Pipeline.create();
pipeline.readFrom(TestSources.items(input)).map(name -> Person.newBuilder().setName(name).build()).groupingKey(identity()).filterUsingService(sharedService(ctx -> null), (s, k, v) -> true).map(person -> person.getName()).writeTo(AssertionSinks.assertAnyOrder(input));
client().getJet().newJob(pipeline, new JobConfig().registerSerializer(Person.class, PersonSerializer.class)).join();
}
use of com.hazelcast.jet.protobuf.Messages.Person in project hazelcast by hazelcast.
the class ProtobufSerializerTest method when_serializes_then_isAbleToDeserialize.
@Test
public void when_serializes_then_isAbleToDeserialize() {
// Given
Person original = Person.newBuilder().setName("Joe").setAge(18).build();
StreamSerializer<Person> serializer = ProtobufSerializer.from(Person.class, 1);
// When
Person transformed = deserialize(serializer, serialize(serializer, original));
// Then
assertThat(transformed).isEqualTo(original);
}
use of com.hazelcast.jet.protobuf.Messages.Person in project hazelcast by hazelcast.
the class JobSerializerTest method when_serializerIsRegistered_then_itIsAvailableForTheJob.
@Test
public void when_serializerIsRegistered_then_itIsAvailableForTheJob() {
String listName = "list-2";
List<Person> list = client().getList(listName);
list.add(Person.newBuilder().setName("Joe").setAge(33).build());
Pipeline pipeline = Pipeline.create();
pipeline.readFrom(Sources.<Person>list(listName)).map(Person::getName).writeTo(AssertionSinks.assertAnyOrder(singletonList("Joe")));
client().getJet().newJob(pipeline, new JobConfig().registerSerializer(Person.class, PersonSerializer.class)).join();
}
Aggregations