Package by.stub.yaml.stubs

Examples of by.stub.yaml.stubs.NotFoundStubResponse


   private StubResponse identifyStubResponseType(final StubHttpLifecycle assertingLifecycle) {

      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();
View Full Code Here


   private StubResponse identifyStubResponseType(final StubHttpLifecycle assertingLifecycle) {

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

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

   @Test
   public void verifyBehaviourDuringHandleGetRequestWithNoResults() throws Exception {

      final String requestPathInfo = "/path/1";

      final NotFoundStubResponse mockStubResponse = Mockito.mock(NotFoundStubResponse.class);

      when(mockHttpServletRequest.getMethod()).thenReturn(HttpMethods.GET);
      when(mockHttpServletRequest.getPathInfo()).thenReturn(requestPathInfo);
      when(mockStubbedDataManager.findStubResponseFor(Mockito.any(StubRequest.class))).thenReturn(mockStubResponse);
      when(mockStubResponse.getStubResponseType()).thenReturn(StubResponseTypes.NOTFOUND);

      final StubsPortalHandler stubsPortalHandler = new StubsPortalHandler(mockStubbedDataManager);
      stubsPortalHandler.handle(requestPathInfo, mockRequest, mockHttpServletRequest, mockHttpServletResponse);

      verify(mockHttpServletResponse, times(1)).setStatus(HttpStatus.NOT_FOUND_404);
View Full Code Here

   public void verifyBehaviourDuringHandlePostRequestWithNoResults() throws Exception {

      final String postData = "postData";
      final String requestPathInfo = "/path/1";

      final NotFoundStubResponse mockStubResponse = Mockito.mock(NotFoundStubResponse.class);

      when(mockHttpServletRequest.getMethod()).thenReturn(HttpMethods.POST);
      when(mockHttpServletRequest.getPathInfo()).thenReturn(requestPathInfo);
      when(mockStubbedDataManager.findStubResponseFor(Mockito.any(StubRequest.class))).thenReturn(mockStubResponse);
      when(mockStubResponse.getStubResponseType()).thenReturn(StubResponseTypes.NOTFOUND);
      final InputStream inputStream = new ByteArrayInputStream(postData.getBytes());
      Mockito.when(mockHttpServletRequest.getInputStream()).thenReturn(new ServletInputStream() {
         @Override
         public int read() throws IOException {
            return inputStream.read();
View Full Code Here

   @Test
   public void verifyBehaviourDuringHandlePostRequestWithMissingPostData() throws Exception {

      final String requestPathInfo = "/path/1";

      final NotFoundStubResponse mockStubResponse = Mockito.mock(NotFoundStubResponse.class);

      when(mockHttpServletRequest.getMethod()).thenReturn(HttpMethods.POST);
      when(mockHttpServletRequest.getPathInfo()).thenReturn(requestPathInfo);
      when(mockStubbedDataManager.findStubResponseFor(Mockito.any(StubRequest.class))).thenReturn(mockStubResponse);

      when(mockStubResponse.getStubResponseType()).thenReturn(StubResponseTypes.OK_200);
      when(mockStubResponse.getStatus()).thenReturn("200");

      final StubsPortalHandler stubsPortalHandler = new StubsPortalHandler(mockStubbedDataManager);
      stubsPortalHandler.handle(requestPathInfo, mockRequest, mockHttpServletRequest, mockHttpServletResponse);

      verify(mockHttpServletResponse, never()).setStatus(HttpStatus.BAD_REQUEST_400);
View Full Code Here

   @Test
   public void verifyBehaviourDuringHandlePostRequestWithEmptyPostData() throws Exception {

      final String requestPathInfo = "/path/1";

      final NotFoundStubResponse mockStubResponse = Mockito.mock(NotFoundStubResponse.class);

      when(mockHttpServletRequest.getMethod()).thenReturn(HttpMethods.POST);
      when(mockHttpServletRequest.getPathInfo()).thenReturn(requestPathInfo);
      when(mockStubbedDataManager.findStubResponseFor(Mockito.any(StubRequest.class))).thenReturn(mockStubResponse);
      when(mockStubResponse.getStubResponseType()).thenReturn(StubResponseTypes.OK_200);
      when(mockStubResponse.getStatus()).thenReturn("200");

      final InputStream inputStream = new ByteArrayInputStream("".getBytes());
      Mockito.when(mockHttpServletRequest.getInputStream()).thenReturn(new ServletInputStream() {
         @Override
         public int read() throws IOException {
View Full Code Here

      assertThat(stubResponseHandlingStrategy).isInstanceOf(DefaultResponseHandlingStrategy.class);
   }

   @Test
   public void shouldIdentifyResponseStrategyForNotFoundResponse() throws Exception {
      final StubResponse stubResponse = new NotFoundStubResponse();

      final StubResponseHandlingStrategy stubResponseHandlingStrategy = StubsResponseHandlingStrategyFactory.getStrategy(stubResponse);
      assertThat(stubResponseHandlingStrategy).isInstanceOf(NotFoundResponseHandlingStrategy.class);
   }
View Full Code Here

   private StubResponse identifyStubResponseType(final StubHttpLifecycle assertingLifecycle) {

      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();
View Full Code Here

   private synchronized StubResponse identifyStubResponseType(final StubHttpLifecycle assertingLifecycle) {

      final int listIndex = stubHttpLifecycles.indexOf(assertingLifecycle);
      if (listIndex < 0) {
         return new NotFoundStubResponse();
      }

      final StubHttpLifecycle matchedLifecycle = stubHttpLifecycles.get(listIndex);
      final StubResponse stubResponse = matchedLifecycle.getResponse();
View Full Code Here

   private StubResponse identifyStubResponseType(final StubHttpLifecycle assertingLifecycle) {

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

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

TOP

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

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.