AbstractOpProcessor implements OpProcessor { protected static Frame makeFrame(final Context ctx, final RequestMessage msg, final MessageSerializer serializer, final boolean useBinary, final List<Object> aggregate, final ResponseStatusCode code, final Map<String,Object> responseMetaData, final Map<String,Object> statusAttributes) throws Exception { try { final ChannelHandlerContext nettyContext = ctx.getChannelHandlerContext(); if (useBinary) { return new Frame(serializer.serializeResponseAsBinary(ResponseMessage.build(msg) .code(code) .statusAttributes(statusAttributes) .responseMetaData(responseMetaData) .result(aggregate).create(), nettyContext.alloc())); } else { final MessageTextSerializer textSerializer = (MessageTextSerializer) serializer; return new Frame(textSerializer.serializeResponseAsString(ResponseMessage.build(msg) .code(code) .statusAttributes(statusAttributes) .responseMetaData(responseMetaData) .result(aggregate).create())); } } catch (Exception ex) { logger.warn("The result [{}] in the request {} could not be serialized and returned.", aggregate, msg.getRequestId(), ex); final String errorMessage = String.format("Error during serialization: %s", ExceptionHelper.getMessageFromExceptionOrCause(ex)); final ResponseMessage error = ResponseMessage.build(msg.getRequestId()) .statusMessage(errorMessage) .statusAttributeException(ex) .code(ResponseStatusCode.SERVER_ERROR_SERIALIZATION).create(); ctx.writeAndFlush(error); throw ex; } } protected  AbstractOpProcessor(final boolean manageTransactions);   }
@Test public void makeFrameMethodTest() throws Exception { final RequestMessage request = RequestMessage.build("test").create(); final Context ctx = Mockito.mock(Context.class); final ArgumentCaptor<ResponseMessage> responseCaptor = ArgumentCaptor.forClass(ResponseMessage.class); try { AbstractOpProcessor.makeFrame(ctx, request, null, true, null, ResponseStatusCode.PARTIAL_CONTENT, null, null); fail("Expected a NullPointerException"); } catch (NullPointerException expected) { } Mockito.verify(ctx, Mockito.times(1)).writeAndFlush(responseCaptor.capture()); assertEquals(ResponseStatusCode.SERVER_ERROR_SERIALIZATION, responseCaptor.getValue().getStatus().getCode()); assertEquals(request.getRequestId(), responseCaptor.getValue().getRequestId()); }