Package by.stub.yaml.stubs

Examples of by.stub.yaml.stubs.StubResponse


         .newStubbedResponse()
         .withLiteralBody("hello").build();

      final List<StubHttpLifecycle> loadedHttpCycles = unmarshall(yaml);
      final StubHttpLifecycle actualHttpLifecycle = loadedHttpCycles.get(0);
      final StubResponse actualResponse = actualHttpLifecycle.getResponse(true);

      assertThat(actualResponse.getStatus()).isEqualTo(String.valueOf(200));
   }
View Full Code Here


         .withStatus("201").build();

      final List<StubHttpLifecycle> loadedHttpCycles = unmarshall(yaml);

      final StubHttpLifecycle actualHttpLifecycle = loadedHttpCycles.get(0);
      final StubResponse actualResponse = actualHttpLifecycle.getResponse(true);

      assertThat(actualResponse.getFile()).isEqualTo(new byte[]{});
      assertThat(StringUtils.newStringUtf8(actualResponse.getResponseBodyAsBytes())).isEqualTo(expectedBody);
   }
View Full Code Here

         .newStubbedResponse()
         .withFoldedBody(stubbedResponseBody).build();

      final List<StubHttpLifecycle> loadedHttpCycles = unmarshall(yaml);
      final StubHttpLifecycle actualHttpLifecycle = loadedHttpCycles.get(0);
      final StubResponse actualResponse = actualHttpLifecycle.getResponse(true);

      assertThat(actualResponse.getBody()).isEqualTo(stubbedResponseBody);
   }
View Full Code Here

         .newStubbedResponse()
         .withLiteralBody(stubbedResponseBody).build();

      final List<StubHttpLifecycle> loadedHttpCycles = unmarshall(yaml);
      final StubHttpLifecycle actualHttpLifecycle = loadedHttpCycles.get(0);
      final StubResponse actualResponse = actualHttpLifecycle.getResponse(true);

      assertThat(actualResponse.getBody()).isEqualTo(stubbedResponseBody);
   }
View Full Code Here

         .withHeaderLocation(location).build();


      final List<StubHttpLifecycle> loadedHttpCycles = unmarshall(yaml);
      final StubHttpLifecycle actualHttpLifecycle = loadedHttpCycles.get(0);
      final StubResponse actualResponse = actualHttpLifecycle.getResponse(true);
      final MapEntry headerOneEntry = MapEntry.entry("location", location);
      final MapEntry headerTwoEntry = MapEntry.entry("content-type", contentType);

      assertThat(actualResponse.getHeaders()).contains(headerOneEntry);
      assertThat(actualResponse.getHeaders()).contains(headerTwoEntry);
   }
View Full Code Here

      final List<StubHttpLifecycle> loadedHttpCycles = unmarshall(String.format("%s\n%s", cycleOne, cycleTwo));
      assertThat(loadedHttpCycles.size()).isEqualTo(2);

      for (int idx = 0; idx < loadedHttpCycles.size(); idx++) {
         final StubHttpLifecycle cycle = loadedHttpCycles.get(idx);
         final StubResponse cycleResponse = cycle.getResponse(true);

         assertThat(cycleResponse.getHeaders()).containsKey(StubResponse.STUBBY_RESOURCE_ID_HEADER);
         assertThat(cycleResponse.getHeaders().get(StubResponse.STUBBY_RESOURCE_ID_HEADER)).isEqualTo(String.valueOf(idx));
      }
   }
View Full Code Here

      final StubHttpLifecycle cycle = loadedHttpCycles.get(0);
      final List<StubResponse> allResponses = cycle.getAllResponses();

      for (int idx = 0; idx < allResponses.size(); idx++) {
         final StubResponse sequenceStubResponse = allResponses.get(idx);
         assertThat(sequenceStubResponse.getHeaders()).containsKey(StubResponse.STUBBY_RESOURCE_ID_HEADER);
         assertThat(sequenceStubResponse.getHeaders().get(StubResponse.STUBBY_RESOURCE_ID_HEADER)).isEqualTo(String.valueOf(0));
      }
   }
View Full Code Here

      for (int resourceId = 0; resourceId < loadedHttpCycles.size(); resourceId++) {
         final StubHttpLifecycle cycle = loadedHttpCycles.get(resourceId);
         final List<StubResponse> allResponses = cycle.getAllResponses();

         for (int sequence = 0; sequence < allResponses.size(); sequence++) {
            final StubResponse sequenceStubResponse = allResponses.get(sequence);
            assertThat(sequenceStubResponse.getHeaders()).containsKey(StubResponse.STUBBY_RESOURCE_ID_HEADER);
            assertThat(sequenceStubResponse.getHeaders().get(StubResponse.STUBBY_RESOURCE_ID_HEADER)).isEqualTo(String.valueOf(resourceId));
         }
      }
   }
View Full Code Here

      final List<StubHttpLifecycle> loadedHttpCycles = loadYamlToDataStore(rawYaml);
      assertThat(loadedHttpCycles.size()).isEqualTo(NUMBER_OF_HTTPCYCLES);

      final StubHttpLifecycle actualHttpLifecycle = loadedHttpCycles.get(498);
      final StubRequest actualRequest = actualHttpLifecycle.getRequest();
      final StubResponse actualResponse = actualHttpLifecycle.getResponse(true);

      assertThat(actualRequest.getUrl()).contains(String.format("%s/%s", baseRequestUrl, 499));
      assertThat(actualRequest.getUrl()).contains(String.format("%s=%s", expectedParamOne, 499));
      assertThat(actualRequest.getUrl()).contains(String.format("%s=%s", expectedParamTwo, 499));

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

   @Test
   public void verifyBehaviourDuringHandleGetRequestWithSomeResults() throws Exception {

      final String requestPathInfo = "/path/1";

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

      when(mockHttpServletResponse.getWriter()).thenReturn(mockPrintWriter);
      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.OK_200);
      when(mockStubResponse.getStatus()).thenReturn("200");
      when(mockStubResponse.getResponseBodyAsBytes()).thenReturn(null);

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

      verify(mockHttpServletResponse, times(1)).setStatus(HttpStatus.OK_200);
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.