package com.github.tomakehurst.wiremock.client;

import org.jmock.Expectations;
import org.jmock.Mockery;
import org.junit.Test;

public class LocalMappingBuilderTest {
    private Mockery context = new Mockery();

    @Test
    public void callingStandardMappingMethodReturnsLocalMappingBuilder() {
        final LocalMappingBuilder mockBuilder = context.mock(LocalMappingBuilder.class);
        context.checking(new Expectations() {{
            oneOf(mockBuilder).willReturn(null);
        }});

        // No assertions necessary: we're just checking that the compiler agrees with the typing - i.e. we're getting
        // a LocalMappingBuilder, not a RemoteMappingBuilder
        LocalMappingBuilder resultingBuilder = mockBuilder.willReturn(null);
    }

    @Test
    public void callingScenarioMappingMethodReturnsScenarioMappingBuilder() {
        final LocalMappingBuilder mockBuilder = context.mock(LocalMappingBuilder.class);
        context.checking(new Expectations() {{
            oneOf(mockBuilder).inScenario("foo");
        }});

        // No assertions necessary: we're just checking that the compiler agrees with the typing
        ScenarioMappingBuilder resultingBuilder = mockBuilder.inScenario("foo");
    }
}
@@ -123,16 +123,134 @@
 .Test;%0A%0A
+import java.lang.reflect.Method;%0A%0Aimport static org.hamcrest.Matchers.is;%0Aimport static org.junit.Assert.assertThat;%0A%0A
 public c
@@ -1344,10 +1344,880 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void localMappingBuilderSpecifiesSameInterfaceAsRemoteMappingBuilder() %7B%0A        Method%5B%5D localMethods = LocalMappingBuilder.class.getDeclaredMethods();%0A        Method%5B%5D remoteMethods = RemoteMappingBuilder.class.getDeclaredMethods();%0A%0A        assertThat(%22LocalMappingBuilder and RemoteMappingBuilder must declare the same methods%22,%0A                localMethods.length, is(remoteMethods.length));%0A%0A        // Note: the following assumes the methods are in the same order, which isn't strictly necessary%0A        for (int i = 0; i %3C localMethods.length; i++) %7B%0A            Method localMethod = localMethods%5Bi%5D;%0A            Method remoteMethod = remoteMethods%5Bi%5D;%0A%0A            assertThat(localMethod.getName(), is(remoteMethod.getName()));%0A            assertThat(localMethod.getParameterTypes(), is(remoteMethod.getParameterTypes()));%0A        %7D%0A    %7D
 %0A%7D

Test to ensure LocalMappingBuilder and RemoteMappingBuilder are the same