test_class.declarator: codec
test_class.modifier: private
test_class.original_string: private AbstractCodec codec;
test_class.type: AbstractCodec
test_class.var_name: codec
test_class.declarator: session
test_class.modifier: private
test_class.original_string: private IoSession session;
test_class.type: IoSession
test_class.var_name: session
test_class.file: BackEnd/Service/service-tcpip/src/test/java/com/exactpro/sf/services/tcpip/TestInternalJsonCodec.java
test_class.identifier: TestInternalJsonCodec
test_class.superclass: extends AbstractTest
test_case.body: @Test
      public void testEncode() throws Exception {
          IMessage msg = new MapMessage("namespace", "name");
          msg.addField("MessageType", 123);
          msg.addField("Qty", 123.123);
          msg.addField("ClOrdID", "");
          msg.addField("fieldDate", LocalDateTime.of(2010, Month.JANUARY, 1, 11, 22, 33, 444_555_666));
  
          ProtocolDecoderOutput decoderOutput = Mockito.mock(ProtocolDecoderOutput.class);
          Mockito.doAnswer(new Answer<Void>() {
              @Override
              public Void answer(InvocationOnMock invocation) throws Throwable {
                  IMessage decoded = invocation.getArgument(0);
  
                  Assert.assertEquals(msg.getFieldNames(), decoded.getFieldNames());
                  for (String column : decoded.getFieldNames()) {
                      Assert.assertEquals(column, msg.<Object>getField(column), decoded.<Object>getField(column));
                  }
                  return null;
              }
          }).when(decoderOutput).write(Mockito.anyObject());
  
          ProtocolEncoderOutput encoderOutput = Mockito.mock(ProtocolEncoderOutput.class);
          Mockito.doAnswer(new Answer<Void>() {
              @Override
              public Void answer(InvocationOnMock invocation) throws Throwable {
                  codec.decode(session, invocation.getArgument(0), decoderOutput);
                  return null;
              }
          } ).when(encoderOutput).write(Mockito.anyObject());
  
          codec.encode(session, msg, encoderOutput);
      }
test_case.class_method_signature: TestInternalJsonCodec.testEncode()
test_case.full_signature: @Test public void testEncode()
test_case.identifier: testEncode
test_case.invocations: addField addField addField addField of mock write when doAnswer getArgument assertEquals getFieldNames getFieldNames getFieldNames assertEquals getField getField anyObject mock write when doAnswer decode getArgument anyObject encode
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testEncode()
focal_class.declarator: logger = LoggerFactory.getLogger(InternalJsonCodec.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(InternalJsonCodec.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: HEADER_SIZE = 8 * 2
focal_class.modifier: private static final
focal_class.original_string: private static final int HEADER_SIZE = 8 * 2;
focal_class.type: int
focal_class.var_name: HEADER_SIZE
focal_class.declarator: objectMapper
focal_class.modifier: private final
focal_class.original_string: private final ObjectMapper objectMapper;
focal_class.type: ObjectMapper
focal_class.var_name: objectMapper
focal_class.declarator: sequence = new AtomicLong(1)
focal_class.modifier: private final
focal_class.original_string: private final AtomicLong sequence = new AtomicLong(1);
focal_class.type: AtomicLong
focal_class.var_name: sequence
focal_class.declarator: msgFactory
focal_class.modifier: private
focal_class.original_string: private IMessageFactory msgFactory;
focal_class.type: IMessageFactory
focal_class.var_name: msgFactory
focal_class.file: BackEnd/Service/service-tcpip/src/main/java/com/exactpro/sf/services/tcpip/InternalJsonCodec.java
focal_class.identifier: InternalJsonCodec
focal_class.class_method_signature: InternalJsonCodec.InternalJsonCodec()
focal_class.full_signature: public  InternalJsonCodec()
focal_class.identifier: InternalJsonCodec
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  InternalJsonCodec()
focal_class.class_method_signature: InternalJsonCodec.encode(IoSession session, Object message, ProtocolEncoderOutput out)
focal_class.full_signature: @Override public void encode(IoSession session, Object message, ProtocolEncoderOutput out)
focal_class.identifier: encode
focal_class.modifiers: @Override public
focal_class.parameters: (IoSession session, Object message, ProtocolEncoderOutput out)
focal_class.return: void
focal_class.signature: void encode(IoSession session, Object message, ProtocolEncoderOutput out)
focal_class.class_method_signature: InternalJsonCodec.init(IServiceContext serviceContext, ICommonSettings settings, IMessageFactory msgFactory, IDictionaryStructure dictionary)
focal_class.full_signature: @Override public void init(IServiceContext serviceContext, ICommonSettings settings, IMessageFactory msgFactory, IDictionaryStructure dictionary)
focal_class.identifier: init
focal_class.modifiers: @Override public
focal_class.parameters: (IServiceContext serviceContext, ICommonSettings settings, IMessageFactory msgFactory, IDictionaryStructure dictionary)
focal_class.return: void
focal_class.signature: void init(IServiceContext serviceContext, ICommonSettings settings, IMessageFactory msgFactory, IDictionaryStructure dictionary)
focal_class.class_method_signature: InternalJsonCodec.doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out)
focal_class.full_signature: @Override protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out)
focal_class.identifier: doDecode
focal_class.modifiers: @Override protected
focal_class.parameters: (IoSession session, IoBuffer in, ProtocolDecoderOutput out)
focal_class.return: boolean
focal_class.signature: boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out)
focal_class.superclass: extends AbstractCodec
focal_method.body: @Override
      public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
          if (message instanceof IMessage) {
              Map<String, Object> map = MessageUtil.convertToHashMap((IMessage)message);
              String json = objectMapper.writeValueAsString(map);
  
              long seq = sequence.getAndIncrement();
  
              IoBuffer buffer = IoBuffer.allocate(json.length() + HEADER_SIZE);
              buffer.putLong(json.length());
              buffer.putLong(seq);
              buffer.put(json.getBytes());
  
              out.write(buffer.flip());
  
              ((IMessage) message).getMetaData().setRawMessage(buffer.array());
  
              if (logger.isDebugEnabled()) {
                  logger.debug("encode() sequnce {} as hex [{}]", seq, buffer.getHexDump());
              }
          } else {
              out.write(message);
          }
      }
focal_method.class_method_signature: InternalJsonCodec.encode(IoSession session, Object message, ProtocolEncoderOutput out)
focal_method.full_signature: @Override public void encode(IoSession session, Object message, ProtocolEncoderOutput out)
focal_method.identifier: encode
focal_method.invocations: convertToHashMap writeValueAsString getAndIncrement allocate length putLong length putLong put getBytes write flip setRawMessage getMetaData array isDebugEnabled debug getHexDump write
focal_method.modifiers: @Override public
focal_method.parameters: (IoSession session, Object message, ProtocolEncoderOutput out)
focal_method.return: void
focal_method.signature: void encode(IoSession session, Object message, ProtocolEncoderOutput out)