Esempio n. 1
0
  @Override
  protected void runChild(Interaction interaction, RunNotifier notifier) {
    final Description description = describeChild(interaction);
    notifier.fireTestStarted(description);

    if (interaction.providerState().isDefined()) {
      final Optional<FrameworkMethod> initializationMethod =
          findProvderStateInitializationMethod(interaction.providerState().get());
      if (initializationMethod.isPresent()) {
        try {
          invokeMethod(initializationMethod.get());
          testPact(interaction);
          notifier.fireTestFinished(description);
          return;
        } catch (Exception ex) {
          notifier.fireTestFailure(new Failure(description, ex));
          return;
        }
      } else {
        notifier.fireTestIgnored(description);
        return;
      }
    }
    notifier.fireTestIgnored(description);
  }
Esempio n. 2
0
 private static void testPact(Interaction interaction) {
   try {
     final ExecutionContextExecutor executionContextExecutor =
         ExecutionContext$.MODULE$.fromExecutor(Executors.newCachedThreadPool());
     final Request request =
         new Request(
             interaction.request().method(),
             "http://localhost:8080" + interaction.request().path(),
             interaction.request().query(),
             interaction.request().headers(),
             interaction.request().body(),
             interaction.request().matchingRules());
     Future<Response> actualResponseFuture = HttpClient.run(request, executionContextExecutor);
     Response actualResponse =
         Await.result(actualResponseFuture, Duration.create(1000, TimeUnit.SECONDS));
     assertEquals(
         FullResponseMatch$.MODULE$,
         ResponseMatching$.MODULE$.matchRules(interaction.response(), actualResponse));
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Esempio n. 3
0
 @Override
 protected Description describeChild(Interaction interaction) {
   return Description.createTestDescription(
       pactToVerify.consumer().name(), interaction.description());
 }