Package by.stub.yaml.stubs

Examples of by.stub.yaml.stubs.StubResponse


         REQUEST_BUILDER
            .withUrl(url)
            .withMethodGet()
            .withHeaders(StubRequest.AUTH_HEADER, "Basic Ym9iOnNlY3JldA==").build()//bob:secret

      final StubResponse foundStubResponse = stubbedDataManager.findStubResponseFor(assertingRequest);

      assertThat(foundStubResponse).isNotInstanceOf(NotFoundStubResponse.class);
      assertThat(foundStubResponse).isInstanceOf(StubResponse.class);
      assertThat(StubResponseTypes.OK_200).isSameAs(foundStubResponse.getStubResponseType());

      assertThat(foundStubResponse.getStatus()).isEqualTo(expectedStatus);
      assertThat(foundStubResponse.getBody()).isEqualTo(expectedBody);
   }
View Full Code Here


      final StubRequest assertingRequest =
         REQUEST_BUILDER
            .withUrl(url)
            .withMethodGet().build();

      final StubResponse foundStubResponse = stubbedDataManager.findStubResponseFor(assertingRequest);

      assertThat(foundStubResponse).isInstanceOf(UnauthorizedStubResponse.class);
      assertThat(StubResponseTypes.UNAUTHORIZED).isSameAs(foundStubResponse.getStubResponseType());

      assertThat(foundStubResponse.getStatus()).isEqualTo("401");
      assertThat(foundStubResponse.getBody()).isEqualTo("");
   }
View Full Code Here

         REQUEST_BUILDER
            .withUrl(url)
            .withMethodGet()
            .withHeaders(StubRequest.AUTH_HEADER, "Basic BadCredentials").build();

      final StubResponse foundStubResponse = stubbedDataManager.findStubResponseFor(assertingRequest);

      assertThat(foundStubResponse).isInstanceOf(UnauthorizedStubResponse.class);
      assertThat(StubResponseTypes.UNAUTHORIZED).isSameAs(foundStubResponse.getStubResponseType());

      assertThat(foundStubResponse.getStatus()).isEqualTo("401");
      assertThat(foundStubResponse.getBody()).isEqualTo("");
   }
View Full Code Here

         REQUEST_BUILDER
            .withUrl(url)
            .withMethodGet()
            .withHeaders(StubRequest.AUTH_HEADER, null).build();

      final StubResponse foundStubResponse = stubbedDataManager.findStubResponseFor(assertingRequest);

      assertThat(foundStubResponse).isInstanceOf(UnauthorizedStubResponse.class);
      assertThat(StubResponseTypes.UNAUTHORIZED).isSameAs(foundStubResponse.getStubResponseType());

      assertThat(foundStubResponse.getStatus()).isEqualTo("401");
      assertThat(foundStubResponse.getBody()).isEqualTo("");
   }
View Full Code Here

      final String resourceId = matchedLifecycle.getResourceId();
      resourceStats.putIfAbsent(resourceId, new AtomicLong(0));
      resourceStats.get(resourceId).incrementAndGet();

      final StubResponse stubResponse = matchedLifecycle.getResponse(true);
      if (matchedLifecycle.isRestricted() && matchedLifecycle.hasNotAuthorized(assertingLifecycle)) {
         return new UnauthorizedStubResponse();
      }

      if (stubResponse.hasHeaderLocation()) {
         return RedirectStubResponse.newRedirectStubResponse(stubResponse);
      }

      if (stubResponse.isRecordingRequired()) {
         final String recordingSource = stubResponse.getBody();
         try {
            final StubbyResponse stubbyResponse = stubbyHttpTransport.fetchRecordableHTTPResponse(matchedLifecycle.getRequest(), recordingSource);
            ReflectionUtils.injectObjectFields(stubResponse, YamlProperties.BODY, stubbyResponse.getContent());
         } catch (Exception e) {
            ANSITerminal.error(String.format("Could not record from %s: %s", recordingSource, e.toString()));
View Full Code Here

      final StubRequest assertingRequest =
         REQUEST_BUILDER
            .withUrl("/invoice/300")
            .withMethodGet().build();

      final StubResponse foundStubResponse = stubbedDataManager.findStubResponseFor(assertingRequest);

      assertThat(foundStubResponse).isInstanceOf(NotFoundStubResponse.class);
      assertThat(StubResponseTypes.NOTFOUND).isSameAs(foundStubResponse.getStubResponseType());

      assertThat(foundStubResponse.getStatus()).isEqualTo("404");
      assertThat(foundStubResponse.getBody()).isEqualTo("");
   }
View Full Code Here

         REQUEST_BUILDER
            .withUrl(url)
            .withMethodPost()
            .withPost(postData).build();

      final StubResponse foundStubResponse = stubbedDataManager.findStubResponseFor(assertingRequest);

      assertThat(foundStubResponse).isNotInstanceOf(NotFoundStubResponse.class);
      assertThat(foundStubResponse).isInstanceOf(StubResponse.class);
      assertThat(StubResponseTypes.OK_200).isSameAs(foundStubResponse.getStubResponseType());

      assertThat(foundStubResponse.getStatus()).isEqualTo(expectedStatus);
      assertThat(foundStubResponse.getBody()).isEqualTo(expectedBody);
   }
View Full Code Here

      final StubRequest assertingRequest =
         REQUEST_BUILDER
            .withUrl(url)
            .withMethodPost().build();

      final StubResponse foundStubResponse = stubbedDataManager.findStubResponseFor(assertingRequest);

      assertThat(foundStubResponse).isInstanceOf(NotFoundStubResponse.class);
      assertThat(StubResponseTypes.NOTFOUND).isSameAs(foundStubResponse.getStubResponseType());

      assertThat(foundStubResponse.getStatus()).isEqualTo("404");
      assertThat(foundStubResponse.getBody()).isEqualTo("");
   }
View Full Code Here

      final StubRequest assertingRequest =
         REQUEST_BUILDER
            .withUrl(url)
            .withMethodPost().build();

      final StubResponse foundStubResponse = stubbedDataManager.findStubResponseFor(assertingRequest);

      assertThat(foundStubResponse).isInstanceOf(NotFoundStubResponse.class);
      assertThat(StubResponseTypes.NOTFOUND).isSameAs(foundStubResponse.getStubResponseType());

      assertThat(foundStubResponse.getStatus()).isEqualTo("404");
      assertThat(foundStubResponse.getBody()).isEqualTo("");
   }
View Full Code Here

      ConsoleUtils.logIncomingRequest(request);

      baseRequest.setHandled(true);

      final StubRequest assertionStubRequest = StubRequest.createFromHttpServletRequest(request);
      final StubResponse foundStubResponse = stubbedDataManager.findStubResponseFor(assertionStubRequest);
      final StubResponseHandlingStrategy strategyStubResponse = StubsResponseHandlingStrategyFactory.getStrategy(foundStubResponse);
      final HttpServletResponseWithGetStatus wrapper = new HttpServletResponseWithGetStatus(response);

      try {
         strategyStubResponse.handle(wrapper, assertionStubRequest);
View Full Code Here

TOP

Related Classes of by.stub.yaml.stubs.StubResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.