Search in sources :

Example 1 with Printer

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));
}
Also used : IntOrString(io.kubernetes.client.proto.IntStr.IntOrString) Printer(io.seldon.clustermanager.pb.JsonFormat.Printer) Test(org.junit.Test)

Example 2 with Printer

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 + "\""));
}
Also used : IntOrString(io.kubernetes.client.proto.IntStr.IntOrString) IntOrString(io.kubernetes.client.proto.IntStr.IntOrString) Printer(io.seldon.clustermanager.pb.JsonFormat.Printer) Test(org.junit.Test)

Example 3 with Printer

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 + "\"}"));
}
Also used : IntOrString(io.kubernetes.client.proto.IntStr.IntOrString) IntOrString(io.kubernetes.client.proto.IntStr.IntOrString) Printer(io.seldon.clustermanager.pb.JsonFormat.Printer) Test(org.junit.Test)

Example 4 with Printer

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 + "}"));
}
Also used : IntOrString(io.kubernetes.client.proto.IntStr.IntOrString) Printer(io.seldon.clustermanager.pb.JsonFormat.Printer) Test(org.junit.Test)

Example 5 with Printer

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 + "\""));
}
Also used : Quantity(io.kubernetes.client.proto.Resource.Quantity) IntOrString(io.kubernetes.client.proto.IntStr.IntOrString) Printer(io.seldon.clustermanager.pb.JsonFormat.Printer) Test(org.junit.Test)

Aggregations

IntOrString (io.kubernetes.client.proto.IntStr.IntOrString)6 Printer (io.seldon.clustermanager.pb.JsonFormat.Printer)6 Test (org.junit.Test)5 JSON (io.kubernetes.client.JSON)1 V1PodTemplateSpec (io.kubernetes.client.models.V1PodTemplateSpec)1 Quantity (io.kubernetes.client.proto.Resource.Quantity)1 Type (java.lang.reflect.Type)1