package com.agilex.healthcare.schedulingmanager.linkbuilder;

import com.agilex.healthcare.schedulingmanager.domain.SchedulingClinic;
import com.agilex.healthcare.schedulingmanager.domain.SchedulingClinics;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.net.URI;
import java.net.URISyntaxException;

/**
 * Created by
 * User: ralph
 * Date: 11/5/13
 * Time: 5:28 PM
 */
public class ClinicLinkBuilderTest extends TestCase {

    public static final String    TEST_URI = "http://localhost:8080/MobileHealthcare";
    public static final String    TEST_FACILITY = "777";

    public static final String      RESULT_URL = TEST_URI + "/scheduling-service/site/"
                                                + TEST_FACILITY + "/available-appointment-slots/clinic/12345";

    @Before
    public void setup() {

    }

    @After
    public void teardown() {

    }

    @Test
    public void  testFillLinks()
            throws URISyntaxException {
        ClinicLinkBuilder     linkBuilder = new ClinicLinkBuilder(new URI(TEST_URI), TEST_FACILITY);
        SchedulingClinics               inputClinics = new SchedulingClinics();
        SchedulingClinics               clinics = new SchedulingClinics();
        SchedulingClinic clinic = new SchedulingClinic();

        clinic.setId("12345");
        inputClinics.add(clinic);

        clinic = new SchedulingClinic();
        clinic.setId("987654");
        inputClinics.add(clinic);

        clinics = linkBuilder.fillLinks(inputClinics);

        clinic = clinics.get(0);

        assertEquals("The URL was not built correctly", RESULT_URL, clinic.getLink().get(0).getHref().toString());
    }
}
