Search in sources :

Example 51 with ByteString

use of com.google.protobuf.ByteString in project java-tron by tronprotocol.

the class AccountCapsuleTest method init.

@BeforeClass
public static void init() {
    Args.setParam(new String[] { "-d", dbPath, "-w" }, Configuration.getByPath(Constant.TEST_CONF));
    ByteString accountName = ByteString.copyFrom(AccountCapsuleTest.randomBytes(16));
    ByteString address = ByteString.copyFrom(AccountCapsuleTest.randomBytes(32));
    AccountType accountType = AccountType.forNumber(1);
    accountCapsuleTest = new AccountCapsule(accountName, address, accountType);
    byte[] accountByte = accountCapsuleTest.getData();
    accountCapsule = new AccountCapsule(accountByte);
    accountCapsuleTest.setBalance(1111L);
}
Also used : ByteString(com.google.protobuf.ByteString) AccountType(org.tron.protos.Protocol.AccountType) BeforeClass(org.junit.BeforeClass)

Example 52 with ByteString

use of com.google.protobuf.ByteString in project java-tron by tronprotocol.

the class AccountTest method getAccountName.

@Test
public void getAccountName() {
    byte[] bytes = ByteArray.fromString("tron");
    if (ArrayUtils.isNotEmpty(bytes)) {
        ByteString accountName = ByteString.copyFrom(bytes);
        Assert.assertEquals(accountName, account.getAccountName());
    }
}
Also used : ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 53 with ByteString

use of com.google.protobuf.ByteString in project java-tron by tronprotocol.

the class AccountTest method setAccountNameRight.

@Test
public void setAccountNameRight() {
    account.setAccountName("tron-name");
    byte[] bytes = ByteArray.fromString("tron-name");
    if (ArrayUtils.isNotEmpty(bytes)) {
        ByteString accountName = ByteString.copyFrom(bytes);
        Assert.assertEquals(accountName, account.getAccountName());
    }
}
Also used : ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 54 with ByteString

use of com.google.protobuf.ByteString in project openzaly by akaxincom.

the class U2MessageTextHandler method handle.

public Boolean handle(Command command) {
    try {
        ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.parseFrom(command.getParams());
        int type = request.getType().getNumber();
        if (CoreProto.MsgType.TEXT_VALUE == type) {
            String siteUserId = command.getSiteUserId();
            String siteFriendId = request.getText().getSiteFriendId();
            String msgId = request.getText().getMsgId();
            ByteString byteStr = request.getText().getText();
            String msgText = byteStr.toString(Charset.forName("UTF-8"));
            command.setSiteFriendId(siteFriendId);
            long msgTime = System.currentTimeMillis();
            U2MessageBean u2Bean = new U2MessageBean();
            u2Bean.setMsgId(msgId);
            u2Bean.setMsgType(type);
            u2Bean.setSendUserId(siteUserId);
            u2Bean.setSiteUserId(siteFriendId);
            u2Bean.setContent(msgText);
            u2Bean.setMsgTime(msgTime);
            LogUtils.requestDebugLog(logger, command, u2Bean.toString());
            boolean success = messageDao.saveU2Message(u2Bean);
            msgStatusResponse(command, msgId, msgTime, success);
            return success;
        }
        return true;
    } catch (Exception e) {
        LogUtils.requestErrorLog(logger, command, this.getClass(), e);
    }
    return false;
}
Also used : U2MessageBean(com.akaxin.site.storage.bean.U2MessageBean) ByteString(com.google.protobuf.ByteString) ByteString(com.google.protobuf.ByteString) ImCtsMessageProto(com.akaxin.proto.site.ImCtsMessageProto)

Example 55 with ByteString

use of com.google.protobuf.ByteString in project openzaly by akaxincom.

the class U2MessageTextSecretHandler method handle.

public Boolean handle(Command command) {
    ChannelSession channelSession = command.getChannelSession();
    try {
        ImCtsMessageProto.ImCtsMessageRequest request = ImCtsMessageProto.ImCtsMessageRequest.parseFrom(command.getParams());
        int type = request.getType().getNumber();
        if (CoreProto.MsgType.SECRET_TEXT_VALUE == type) {
            String siteUserId = command.getSiteUserId();
            String siteFriendId = command.getSiteFriendId();
            String msgId = request.getSecretText().getMsgId();
            String tsKey = request.getSecretText().getTsKey();
            String tsDeviceId = request.getSecretText().getSiteDeviceId();
            ByteString byteStr = request.getSecretText().getText();
            String msgText = Base64.getEncoder().encodeToString(byteStr.toByteArray());
            long msgTime = System.currentTimeMillis();
            U2MessageBean u2Bean = new U2MessageBean();
            u2Bean.setMsgId(msgId);
            u2Bean.setMsgType(type);
            u2Bean.setSendUserId(siteUserId);
            u2Bean.setSiteUserId(siteFriendId);
            u2Bean.setContent(msgText);
            u2Bean.setTsKey(tsKey);
            u2Bean.setDeviceId(tsDeviceId);
            u2Bean.setMsgTime(msgTime);
            LogUtils.requestDebugLog(logger, command, u2Bean.toString());
            boolean success = messageDao.saveU2Message(u2Bean);
            msgStatusResponse(command, msgId, msgTime, success);
            return success;
        }
        return true;
    } catch (Exception e) {
        LogUtils.requestErrorLog(logger, command, this.getClass(), e);
    }
    return false;
}
Also used : U2MessageBean(com.akaxin.site.storage.bean.U2MessageBean) ChannelSession(com.akaxin.common.channel.ChannelSession) ByteString(com.google.protobuf.ByteString) ByteString(com.google.protobuf.ByteString) ImCtsMessageProto(com.akaxin.proto.site.ImCtsMessageProto)

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