Package by.stub.yaml.stubs

Examples of by.stub.yaml.stubs.StubResponse


      final StubHttpLifecycle matchedLifecycle = getMatchedStubHttpLifecycle(assertingLifecycle);
      if (ObjectUtils.isNull(matchedLifecycle)) {
         return new NotFoundStubResponse();
      }

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

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

      return stubResponse;
   }
View Full Code Here


         stubHttpLifecycle.setRequest(targetStub);

         ConsoleUtils.logUnmarshalledStubRequest(targetStub.getMethod(), targetStub.getUrl());

      } else {
         final StubResponse targetStub = unmarshallYamlMapToTargetStub(yamlProperties, StubResponseBuilder.class);
         stubHttpLifecycle.setResponse(targetStub);
      }
   }
View Full Code Here

         stubHttpLifecycle.setRequest(targetStub);

         ConsoleUtils.logUnmarshalledStubRequest(targetStub.getMethod(), targetStub.getUrl());

      } else {
         final StubResponse targetStub = unmarshallYamlMapToTargetStub(yamlProperties, new StubResponseBuilder());
         stubHttpLifecycle.setResponse(targetStub);
      }
   }
View Full Code Here

   }

   @Override
   public StubResponse build()  throws Exception {
      ReflectionUtils.injectObjectFields(this, fieldNameAndValues);
      return new StubResponse(status, body, file, latency, headers);
   }
View Full Code Here

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

      final StubResponse foundStubResponse = stubbedDataManager.findStubResponseFor(assertingRequest);
      assertThat(foundStubResponse).isInstanceOf(StubResponse.class);
      assertThat(StubResponseTypes.OK_200).isSameAs(foundStubResponse.getStubResponseType());

      assertThat(foundStubResponse.getStatus()).isEqualTo(sequenceResponseStatus);
      assertThat(foundStubResponse.getBody()).isEqualTo(sequenceResponseBody);

      final MapEntry mapEntry = MapEntry.entry(sequenceResponseHeaderKey, sequenceResponseHeaderValue);
      assertThat(foundStubResponse.getHeaders()).contains(mapEntry);
   }
View Full Code Here

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

      final StubResponse irrelevantFirstSequenceResponse = stubbedDataManager.findStubResponseFor(assertingRequest);
      final StubResponse foundStubResponse = stubbedDataManager.findStubResponseFor(assertingRequest);

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

      assertThat(foundStubResponse.getStatus()).isEqualTo(sequenceResponseStatus);
      assertThat(foundStubResponse.getBody()).isEqualTo(sequenceResponseBody);

      final MapEntry mapEntry = MapEntry.entry(sequenceResponseHeaderKey, sequenceResponseHeaderValue);
      assertThat(foundStubResponse.getHeaders()).contains(mapEntry);
   }
View Full Code Here

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

      final StubResponse irrelevantFirstSequenceResponse = stubbedDataManager.findStubResponseFor(assertingRequest);
      final StubResponse irrelevantLastSequenceResponse = stubbedDataManager.findStubResponseFor(assertingRequest);
      final StubResponse firstSequenceResponseRestarted = stubbedDataManager.findStubResponseFor(assertingRequest);

      assertThat(firstSequenceResponseRestarted).isInstanceOf(StubResponse.class);
      assertThat(StubResponseTypes.OK_200).isSameAs(firstSequenceResponseRestarted.getStubResponseType());

      assertThat(firstSequenceResponseRestarted.getStatus()).isEqualTo(sequenceResponseStatus);
      assertThat(firstSequenceResponseRestarted.getBody()).isEqualTo(sequenceResponseBody);

      final MapEntry mapEntry = MapEntry.entry(sequenceResponseHeaderKey, sequenceResponseHeaderValue);
      assertThat(firstSequenceResponseRestarted.getHeaders()).contains(mapEntry);
   }
View Full Code Here

         final boolean isResponsesSequenced =  allResponses.size() == 1 ? false : true;
         final int nextSequencedResponseId = stubHttpLifecycle.getNextSequencedResponseId();
         final String nextResponseLabel = (isResponsesSequenced && nextSequencedResponseId == sequenceId ? NEXT_IN_THE_QUEUE : "");
         final String responseTableTitle = (isResponsesSequenced ? String.format("%s/%s%s", YamlProperties.RESPONSE, sequenceId, nextResponseLabel) : YamlProperties.RESPONSE);
         final StubResponse stubResponse = allResponses.get(sequenceId);
         final Map<String, String> stubResponseProperties = ReflectionUtils.getProperties(stubResponse);
         final StringBuilder sequencedResponseBuilder = buildStubHtmlTableBody(resourceId, responseTableTitle, stubResponseProperties);
         final String ajaxLinkToResponseAsYaml = String.format(TEMPLATE_AJAX_TO_RESOURCE_HYPERLINK, resourceId, YamlProperties.HTTPLIFECYCLE, "responseAsYaml");
         sequencedResponseBuilder.append(interpolateHtmlTableRowTemplate("RAW YAML", ajaxLinkToResponseAsYaml));
View Full Code Here

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

      final StubResponse foundStubResponse = stubbedDataManager.findStubResponseFor(assertingRequest);

      assertThat(foundStubResponse).isInstanceOf(RedirectStubResponse.class);
      assertThat(StubResponseTypes.REDIRECT).isSameAs(foundStubResponse.getStubResponseType());

      assertThat(foundStubResponse.getStatus()).isEqualTo(expectedStatus);
      assertThat(foundStubResponse.getBody()).isEqualTo(expectedBody);

      final MapEntry mapEntry = MapEntry.entry(expectedHeaderKey, expectedHeaderValue);
      assertThat(foundStubResponse.getHeaders()).contains(mapEntry);
   }
View Full Code Here

      final StubRequest assertingRequest =
         REQUEST_BUILDER
            .withUrl(url)
            .withMethodGet().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

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.