@Test public void preHandle(@Injectable HttpServletRequest request) throws Exception { DtmHandlerInterceptor dtmHandlerInterceptor = new DtmHandlerInterceptor(); DtmContextDTO dtmContextDTO = new DtmContextDTO(); dtmContextDTO.setGlobalTxId(100); new Expectations() { { request.getHeader(DtmConstants.DTM_CONTEXT); result = Json.encode(dtmContextDTO); } }; dtmHandlerInterceptor.preHandle(request, null, null); assertEquals(DTMContext.getDTMContext().getGlobalTxId(), 100); }
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { DTMContext dtmContext = DTMContext.getDTMContext(); String dtmHeader = request.getHeader(DtmConstants.DTM_CONTEXT); if (StringUtils.isNotEmpty(dtmHeader)) { DtmContextDTO dtmContextDTO = Json.decodeValue(dtmHeader, DtmContextDTO.class); LOGGER.debug("dtm info, provider dtmContextDTO:" + dtmContextDTO); transform(dtmContext, dtmContextDTO); } return true; }
DtmHandlerInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { DTMContext dtmContext = DTMContext.getDTMContext(); String dtmHeader = request.getHeader(DtmConstants.DTM_CONTEXT); if (StringUtils.isNotEmpty(dtmHeader)) { DtmContextDTO dtmContextDTO = Json.decodeValue(dtmHeader, DtmContextDTO.class); LOGGER.debug("dtm info, provider dtmContextDTO:" + dtmContextDTO); transform(dtmContext, dtmContextDTO); } return true; } }
DtmHandlerInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { DTMContext dtmContext = DTMContext.getDTMContext(); String dtmHeader = request.getHeader(DtmConstants.DTM_CONTEXT); if (StringUtils.isNotEmpty(dtmHeader)) { DtmContextDTO dtmContextDTO = Json.decodeValue(dtmHeader, DtmContextDTO.class); LOGGER.debug("dtm info, provider dtmContextDTO:" + dtmContextDTO); transform(dtmContext, dtmContextDTO); } return true; }  }
DtmHandlerInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { DTMContext dtmContext = DTMContext.getDTMContext(); String dtmHeader = request.getHeader(DtmConstants.DTM_CONTEXT); if (StringUtils.isNotEmpty(dtmHeader)) { DtmContextDTO dtmContextDTO = Json.decodeValue(dtmHeader, DtmContextDTO.class); LOGGER.debug("dtm info, provider dtmContextDTO:" + dtmContextDTO); transform(dtmContext, dtmContextDTO); } return true; }  @Override boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler); }
DtmHandlerInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { DTMContext dtmContext = DTMContext.getDTMContext(); String dtmHeader = request.getHeader(DtmConstants.DTM_CONTEXT); if (StringUtils.isNotEmpty(dtmHeader)) { DtmContextDTO dtmContextDTO = Json.decodeValue(dtmHeader, DtmContextDTO.class); LOGGER.debug("dtm info, provider dtmContextDTO:" + dtmContextDTO); transform(dtmContext, dtmContextDTO); } return true; }  @Override boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler);  }