package com.worth.ifs.organisation.controller;

import com.worth.ifs.BaseControllerIntegrationTest;
import com.worth.ifs.organisation.resource.CompanyHouseBusiness;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import static org.junit.Assert.*;

public class CompanyHouseControllerIntegrationTest extends BaseControllerIntegrationTest<CompanyHouseController> {

    private String COMPANY_ID = "08241216";
    private String COMPANY_NAME = "NETWORTHNET LTD";

    @Override
    @Autowired
    protected void setControllerUnderTest(CompanyHouseController controller) {
        this.controller = controller;
    }

    @Test
    public void testSearchCompanyHouseName() throws Exception {
        List<CompanyHouseBusiness> companies = controller.searchCompanyHouse("Batman Robin");
        assertEquals(1, companies.size());
    }
    @Test
    public void testSearchCompanyHouseNumber() throws Exception {
        List<CompanyHouseBusiness> companies = controller.searchCompanyHouse(COMPANY_ID);
        assertEquals(1, companies.size());
        CompanyHouseBusiness company = companies.get(0);

        assertNotNull(company);
        assertEquals(COMPANY_NAME, company.getName());
        assertEquals(COMPANY_ID, company.getCompanyNumber());
        assertEquals("ltd", company.getType());
        assertEquals("MONTROSE HOUSE", company.getOfficeAddress().getAddressLine1());
        assertEquals("CLAYHILL PARK", company.getOfficeAddress().getAddressLine2());
        assertEquals("NESTON", company.getOfficeAddress().getLocality());
        assertEquals("CHESHIRE", company.getOfficeAddress().getRegion());
        assertEquals("CH64 3RU", company.getOfficeAddress().getPostalCode());
    }

    @Test
    public void testGetCompanyHouse() throws Exception {
        CompanyHouseBusiness company = controller.getCompanyHouse(COMPANY_ID);
        assertNotNull(company);
        assertEquals(COMPANY_NAME, company.getName());
        assertEquals(COMPANY_ID, company.getCompanyNumber());
        assertEquals("ltd", company.getType());
        assertEquals("Montrose House", company.getOfficeAddress().getAddressLine1());
        assertEquals("Clayhill Park", company.getOfficeAddress().getAddressLine2());
        assertEquals("Neston", company.getOfficeAddress().getLocality());
        assertEquals("Cheshire", company.getOfficeAddress().getRegion());
        assertEquals("CH64 3RU", company.getOfficeAddress().getPostalCode());
    }

    @Test
    public void testGetCompanyHouseNotExisting() throws Exception {
        CompanyHouseBusiness company = controller.getCompanyHouse(String.valueOf(Integer.MAX_VALUE));
        assertNull(company);
    }
}
@@ -1379,21 +1379,21 @@
 s(%22M
-ONTROSE HOUSE
+ontrose House
 %22, c
@@ -1465,20 +1465,20 @@
 s(%22C
-LAYHILL PARK
+layhill Park
 %22, c
@@ -1550,13 +1550,13 @@
 s(%22N
-ESTON
+eston
 %22, c
@@ -1624,15 +1624,15 @@
 s(%22C
-HESHIRE
+heshire
 %22, c

Fix the broken test on companies house