Exemple #1
0
 private List<Session> prepareTargetSessions(Session targetSession) {
   List<Session> sessions = restoreSessions(this.file);
   Optional<Session> session = tryFind(sessions, isForRequest(targetSession.getRequest()));
   if (session.isPresent()) {
     session.get().setResponse(targetSession.getResponse());
   } else {
     sessions.add(targetSession);
   }
   return sessions;
 }
Exemple #2
0
 public void onCompleteResponse(FullHttpRequest request, FullHttpResponse response) {
   try {
     ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
     Session targetSession =
         Session.newSession(
             MessageFactory.createRequest(request), MessageFactory.createResponse(response));
     writer.writeValue(this.file, prepareTargetSessions(targetSession));
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }