<commit_before>package org.incode.module.commchannel.dom.api.geocoding;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.UnknownHostException;

import org.jmock.Expectations;
import org.jmock.auto.Mock;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import org.apache.isis.applib.DomainObjectContainer;
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;

import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assume.assumeThat;

public class GeocodingServiceTest {

    @Rule
    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(JUnitRuleMockery2.Mode.INTERFACES_AND_CLASSES);

    GeocodingService geocodingService;
    @Mock
    DomainObjectContainer mockContainer;

    public static class LookupTest extends GeocodingServiceTest {

        @Before
        public void setUp() throws Exception {
            geocodingService = new GeocodingService();
            geocodingService.container = mockContainer;
        }

        @Test
        public void normal_mode() throws Exception {

            assumeThat(isInternetReachable(), is(true));

            // when
            final String address = geocodingService.combine(GeocodingService.Encoding.ENCODED, "45 High Street, Oxford", null, "UK");
            final GeocodedAddress geocodedAddress = geocodingService.lookup(address);

            // then
            assertThat(geocodedAddress).isNotNull();
            assertThat(geocodedAddress.getStatus()).isEqualTo(GeocodeApiResponse.Status.OK);
            assertThat(geocodedAddress.getFormattedAddress()).isEqualTo("45 High St, Oxford, Oxfordshire OX1, UK");
            assertThat(geocodedAddress.getPlaceId()).isEqualTo("Eic0NSBIaWdoIFN0LCBPeGZvcmQsIE94Zm9yZHNoaXJlIE9YMSwgVUs");
            assertThat(geocodedAddress.getPostalCode()).isEqualTo("OX1");
            assertThat(geocodedAddress.getCountry()).isEqualTo("United Kingdom");
        }
<commit_msg>Fixing broken tests resulting from changes in output from the actual (google) GeocodingService.<commit_after>package org.incode.module.commchannel.dom.api.geocoding;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.UnknownHostException;

import org.jmock.Expectations;
import org.jmock.auto.Mock;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import org.apache.isis.applib.DomainObjectContainer;
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;

import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assume.assumeThat;

public class GeocodingServiceTest {

    @Rule
    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(JUnitRuleMockery2.Mode.INTERFACES_AND_CLASSES);

    GeocodingService geocodingService;
    @Mock
    DomainObjectContainer mockContainer;

    public static class LookupTest extends GeocodingServiceTest {

        @Before
        public void setUp() throws Exception {
            geocodingService = new GeocodingService();
            geocodingService.container = mockContainer;
        }

        @Test
        public void normal_mode() throws Exception {

            assumeThat(isInternetReachable(), is(true));

            // when
            final String address = geocodingService.combine(GeocodingService.Encoding.ENCODED, "45 High Street, Oxford", null, "UK");
            final GeocodedAddress geocodedAddress = geocodingService.lookup(address);

            // then
            assertThat(geocodedAddress).isNotNull();
            assertThat(geocodedAddress.getStatus()).isEqualTo(GeocodeApiResponse.Status.OK);
            assertThat(geocodedAddress.getFormattedAddress()).startsWith("45 High St, Oxford, Oxfordshire OX1");
            assertThat(geocodedAddress.getFormattedAddress()).endsWith("UK");
            assertThat(geocodedAddress.getPlaceId()).isNotNull();
            assertThat(geocodedAddress.getPostalCode()).startsWith("OX1");
            assertThat(geocodedAddress.getCountry()).isEqualTo("United Kingdom");
        }

{'fraction_non_alphanumeric': 0.0928520541439088, 'fraction_numerical': 0.006174305390643553, 'mean_word_length': 3.797266514806378, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2774709', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1210, 'n_words': 212}