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));
}
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));
}
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));
}
Aggregations