Search in sources :

Example 6 with EndpointDefinition

use of uk.gov.justice.services.clients.core.EndpointDefinition in project microservice_framework by CJSCommonPlatform.

the class BaseUriFactoryTest method shouldCreateABaseUriWithTheMockServerPortIfSet.

@Test
public void shouldCreateABaseUriWithTheMockServerPortIfSet() {
    final Optional<String> mockServerPort = of("8989");
    final String baseUri = "http://localhost:8080/anyUrl";
    final String resultUri = "http://localhost:8989/anyUrl";
    final EndpointDefinition endpointDefinition = mock(EndpointDefinition.class);
    when(endpointDefinition.getBaseUri()).thenReturn(baseUri);
    when(mockServerPortProvider.getMockServerPort(endpointDefinition)).thenReturn(mockServerPort);
    assertThat(baseUriFactory.createBaseUri(endpointDefinition), is(resultUri));
}
Also used : EndpointDefinition(uk.gov.justice.services.clients.core.EndpointDefinition) Test(org.junit.Test)

Example 7 with EndpointDefinition

use of uk.gov.justice.services.clients.core.EndpointDefinition in project microservice_framework by CJSCommonPlatform.

the class MockServerPortProviderTest method shouldReturnMockServerPortIfSystemPropertySetAndIsNotTheSameService.

@Test
public void shouldReturnMockServerPortIfSystemPropertySetAndIsNotTheSameService() throws Exception {
    final String port = "1234";
    System.setProperty(MOCK_SERVER_PORT, port);
    final EndpointDefinition endpointDefinition = mock(EndpointDefinition.class);
    when(contextMatcher.isSameContext(endpointDefinition)).thenReturn(false);
    final Optional<String> mockServerPort = mockServerPortProvider.getMockServerPort(endpointDefinition);
    assertThat(mockServerPort.isPresent(), is(true));
    assertThat(mockServerPort.get(), is(port));
}
Also used : EndpointDefinition(uk.gov.justice.services.clients.core.EndpointDefinition) Test(org.junit.Test)

Example 8 with EndpointDefinition

use of uk.gov.justice.services.clients.core.EndpointDefinition in project microservice_framework by CJSCommonPlatform.

the class ContextMatcherTest method shouldReturnTrueIfTheCurrentServiceAndTheRemoteServiceAreTheSameContext.

@Test
public void shouldReturnTrueIfTheCurrentServiceAndTheRemoteServiceAreTheSameContext() throws Exception {
    final String localServiceContextName = "notification-command-api";
    final String baseUri = "http://localhost:8080/notification-command-api/command/api/rest/notification";
    final EndpointDefinition endpointDefinition = mock(EndpointDefinition.class);
    when(contextNameProvider.getServiceContextName()).thenReturn(localServiceContextName);
    when(endpointDefinition.getBaseUri()).thenReturn(baseUri);
    assertThat(contextMatcher.isSameContext(endpointDefinition), is(true));
}
Also used : EndpointDefinition(uk.gov.justice.services.clients.core.EndpointDefinition) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 EndpointDefinition (uk.gov.justice.services.clients.core.EndpointDefinition)8