Пример #1
0
  @Test
  public void shouldGetEnvProps() throws IOException, URISyntaxException {
    // Given
    String url = "http://localhost:8080/%s/version";
    MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);
    String body = loadJsonFile();
    mockServer
        .expect(requestTo("http://localhost:8080/test/version"))
        .andExpect(method(HttpMethod.GET))
        .andRespond(withSuccess(body, MediaType.APPLICATION_JSON));
    willReturn(restTemplate).given(restClient).getRestTemplate();
    restClient.setUrl(url);

    // When
    EnvironmentProperties environmentProperties = restClient.getEnvironmentProperties("test");

    // Then
    Assert.assertEquals(
        "Test expectedName should be", "test", environmentProperties.getTest().getExpectedName());
  }
Пример #2
0
  @Test
  public void shouldGetVersion() {
    // Given
    MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);
    String body = "1.2.0.SNAPSHOT";
    String expectedUri = "http://localhost:8080/test/version";
    mockServer
        .expect(requestTo(expectedUri))
        .andExpect(method(HttpMethod.GET))
        .andRespond(withSuccess(body, MediaType.TEXT_PLAIN));
    willReturn(restTemplate).given(restClient).getRestTemplate();

    // When
    String version = restClient.getVersionFrom(expectedUri);

    // Then
    Assert.assertEquals("Version should be", body, version);
  }