private void throwTapeNotWritable(String request) { throw new NonWritableTapeException("\n" + "================================================================================\n" + "An HTTP request has been made that OkReplay does not know how to handle:\n" + " " + request + "\n\n" + "Under the current configuration, OkReplay can not find a suitable HTTP interaction\n" + "to replay and is prevented from recording new requests. There are a few ways you\n" + "can configure OkReplay to handle this request:\n\n" + "* If you want OkReplay to record this request and play it back during future test\n" + " runs, you should set your annotation to `@OkReplay(mode = TapeMode.READ_WRITE)`\n" + "* If you believe this request has been already recorded, you can update your\n" + " `MatchRule` to make sure it matches one of the recorded requests by updating\n" + " your annotation like `@OkReplay(match = { ... })`. You can also manually fix your\n" + " tape file(s) to make sure a match can be found. Sometimes the same request is\n" + " made with different parameters between multiple test runs causing the match.\n" + " rule to not find a suitable interaction to replay.\n" + "================================================================================\n"); }
private void throwTapeNotWritable(String request) { throw new NonWritableTapeException("\n" + "================================================================================\n" + "An HTTP request has been made that OkReplay does not know how to handle:\n" + " " + request + "\n\n" + "Under the current configuration, OkReplay can not find a suitable HTTP interaction\n" + "to replay and is prevented from recording new requests. There are a few ways you\n" + "can configure OkReplay to handle this request:\n\n" + "* If you want OkReplay to record this request and play it back during future test\n" + " runs, you should set your annotation to `@OkReplay(mode = TapeMode.READ_WRITE)`\n" + "* If you believe this request has been already recorded, you can update your\n" + " `MatchRule` to make sure it matches one of the recorded requests by updating\n" + " your annotation like `@OkReplay(match = { ... })`. You can also manually fix your\n" + " tape file(s) to make sure a match can be found. Sometimes the same request is\n" + " made with different parameters between multiple test runs causing the match.\n" + " rule to not find a suitable interaction to replay.\n" + "================================================================================\n"); }
@Override public boolean seek(Request request) { if (isSequential()) { try { // TODO: it's a complete waste of time using an AtomicInteger when this method is called // before play in a non-transactional way Integer index = orderedIndex.get(); RecordedInteraction interaction = interactions.get(index).toImmutable(); Request nextRequest = interaction == null ? null : interaction.request(); return nextRequest != null && matchRule.isMatch(request, nextRequest); } catch (IndexOutOfBoundsException e) { throw new NonWritableTapeException(); } } else { return findMatch(request) >= 0; } }
@Override public boolean seek(Request request) { if (isSequential()) { try { // TODO: it's a complete waste of time using an AtomicInteger when this method is called // before play in a non-transactional way Integer index = orderedIndex.get(); RecordedInteraction interaction = interactions.get(index).toImmutable(); Request nextRequest = interaction == null ? null : interaction.request(); return nextRequest != null && matchRule.isMatch(request, nextRequest); } catch (IndexOutOfBoundsException e) { throw new NonWritableTapeException(); } } else { return findMatch(request) >= 0; } }