Search in sources :

Example 36 with ByteString

use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project Protocol-Adapter-OSLP by OSGP.

the class OslpDeviceService method convertMacAddress.

private String convertMacAddress(final ByteString byteString) {
    final StringBuilder stringBuilder = new StringBuilder();
    for (final byte b : byteString.toByteArray()) {
        stringBuilder.append(String.format("%02X", b)).append("-");
    }
    final String macAddress = stringBuilder.toString();
    LOGGER.info("macAddress: {}", macAddress);
    return macAddress.substring(0, macAddress.length() - 1);
}
Also used : ByteString(com.google.protobuf.ByteString)

Example 37 with ByteString

use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project Protocol-Adapter-OSLP by OSGP.

the class OslpGetConfigurationResponseToConfigurationConverter method convertIpAddress.

private String convertIpAddress(final ByteString byteString) {
    if (byteString == null || byteString.isEmpty()) {
        return "";
    }
    LOGGER.debug("byteString.toByteArray().length(): {}", byteString.toByteArray().length);
    final StringBuilder stringBuilder = new StringBuilder();
    for (final byte number : byteString.toByteArray()) {
        int convertedNumber = number;
        if (number < 0) {
            convertedNumber = 256 + number;
        }
        final String str = String.valueOf(convertedNumber);
        stringBuilder.append(str).append(".");
    }
    final String ipValue = stringBuilder.toString();
    return ipValue.substring(0, ipValue.length() - 1);
}
Also used : ByteString(com.google.protobuf.ByteString)

Example 38 with ByteString

use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project core-java by SpineEventEngine.

the class Preconditions2Should method not_accept_empty_ByteString_value.

@Test(expected = IllegalArgumentException.class)
public void not_accept_empty_ByteString_value() {
    final ByteString str = ByteString.EMPTY;
    checkNewValueNotEmpty(str);
}
Also used : ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 39 with ByteString

use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project core-java by SpineEventEngine.

the class ChangesShould method create_byte_string_value_change.

@Test
public void create_byte_string_value_change() {
    final ByteString previousValue = ByteString.copyFromUtf8(randomUuid());
    final ByteString newValue = ByteString.copyFromUtf8(randomUuid());
    final BytesChange result = Changes.of(previousValue, newValue);
    assertEquals(previousValue, result.getPreviousValue());
    assertEquals(newValue, result.getNewValue());
}
Also used : ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 40 with ByteString

use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project baseio by generallycloud.

the class Test method main.

public static void main(String[] args) throws InvalidProtocolBufferException {
    ByteString byteString = ByteString.copyFrom("222".getBytes());
    SearchRequest request = SearchRequest.newBuilder().setCorpus(Corpus.IMAGES).setPageNumber(100).setQuery("test").setQueryBytes(byteString).setResultPerPage(-1).build();
    byte[] data = request.toByteArray();
    SearchRequest r2 = SearchRequest.parseFrom(data);
    System.out.println(r2.toString());
    int i = 0b011111111111111111111111;
    System.out.println(i);
}
Also used : SearchRequest(com.generallycloud.test.io.protobuf.TestProtoBufBean.SearchRequest) ByteString(com.google.protobuf.ByteString)

Aggregations

ByteString (com.google.protobuf.ByteString)406 Test (org.junit.Test)143 ArrayList (java.util.ArrayList)65 ByteString (org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.ByteString)63 HashMap (java.util.HashMap)41 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)40 IOException (java.io.IOException)37 List (java.util.List)33 Map (java.util.Map)33 ServerRequest (com.pokegoapi.main.ServerRequest)17 ExecutionException (java.util.concurrent.ExecutionException)16 AnnotateImageRequest (com.google.cloud.vision.v1.AnnotateImageRequest)14 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)14 BatchAnnotateImagesResponse (com.google.cloud.vision.v1.BatchAnnotateImagesResponse)14 Feature (com.google.cloud.vision.v1.Feature)14 Image (com.google.cloud.vision.v1.Image)14 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)14 FileInputStream (java.io.FileInputStream)13 ByteBuffer (java.nio.ByteBuffer)13 WebImage (com.google.cloud.vision.v1.WebDetection.WebImage)12