Search in sources :

Example 1 with IntOrString

use of io.kubernetes.client.proto.IntStr.IntOrString 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 IntOrString

use of io.kubernetes.client.proto.IntStr.IntOrString 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 IntOrString

use of io.kubernetes.client.proto.IntStr.IntOrString 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 IntOrString

use of io.kubernetes.client.proto.IntStr.IntOrString 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)

Aggregations

IntOrString (io.kubernetes.client.proto.IntStr.IntOrString)4 Printer (io.seldon.clustermanager.pb.JsonFormat.Printer)4 Test (org.junit.Test)4