use of io.seldon.clustermanager.pb.JsonFormat.Printer in project seldon-core by SeldonIO.
the class JsonFormatTest method testIntValCustomFormat.
@Test
public void testIntValCustomFormat() throws InvalidProtocolBufferException {
final int val = 1;
IntOrString is = IntOrString.newBuilder().setIntVal(val).build();
Printer jf = JsonFormat.printer().usingTypeConverter(is.getDescriptorForType().getFullName(), new IntOrStringUtils.IntOrStringConverter());
Assert.assertTrue(jf.print(is).equals("" + val));
}
use of io.seldon.clustermanager.pb.JsonFormat.Printer in project seldon-core by SeldonIO.
the class JsonFormatTest method testStrValCustomFormat.
@Test
public void testStrValCustomFormat() throws InvalidProtocolBufferException {
final String val = "String Value";
IntOrString is = IntOrString.newBuilder().setStrVal(val).build();
Printer jf = JsonFormat.printer().usingTypeConverter(is.getDescriptorForType().getFullName(), new IntOrStringUtils.IntOrStringConverter());
Assert.assertTrue(jf.print(is).equals("\"" + val + "\""));
}
use of io.seldon.clustermanager.pb.JsonFormat.Printer in project seldon-core by SeldonIO.
the class JsonFormatTest method testStrValDefaultFormat.
@Test
public void testStrValDefaultFormat() throws InvalidProtocolBufferException {
final String val = "String Value";
IntOrString is = IntOrString.newBuilder().setStrVal(val).build();
Printer jf = JsonFormat.printer().omittingInsignificantWhitespace();
Assert.assertTrue(jf.print(is).equals("{\"strVal\":\"" + val + "\"}"));
}
use of io.seldon.clustermanager.pb.JsonFormat.Printer in project seldon-core by SeldonIO.
the class JsonFormatTest method testIntValDefaultFormat.
@Test
public void testIntValDefaultFormat() throws InvalidProtocolBufferException {
final int val = 1;
IntOrString is = IntOrString.newBuilder().setIntVal(val).build();
Printer jf = JsonFormat.printer().omittingInsignificantWhitespace();
Assert.assertTrue(jf.print(is).equals("{\"intVal\":" + val + "}"));
}
use of io.seldon.clustermanager.pb.JsonFormat.Printer in project seldon-core by SeldonIO.
the class JsonFormatTest method testQuantityCustomFormat.
@Test
public void testQuantityCustomFormat() throws InvalidProtocolBufferException {
final String val = "100Mi";
Quantity q = Quantity.newBuilder().setString(val).build();
Printer jf = JsonFormat.printer().usingTypeConverter(q.getDescriptorForType().getFullName(), new QuantityUtils.QuantityConverter());
Assert.assertTrue(jf.print(q).equals("\"" + val + "\""));
}
Aggregations