package ca.uhn.fhir.rest.param;

import static org.junit.Assert.*;

import ca.uhn.fhir.model.dstu.composite.CodingDt;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class TokenOrListParamTest {
    @Test
    public void whenParamListHasAnyMatchingCodingsForCodingList_doesCodingListMatch_shouldBeTrue() {
        TokenOrListParam params = new TokenOrListParam();
        params.add("http://foo.org", "53");
        params.add("http://bar.org", "52");

        List<CodingDt> codings = new ArrayList<CodingDt>();
        codings.add(new CodingDt("http://baz.org", "53"));
        codings.add(new CodingDt("http://bar.org", "52"));

        assertTrue(params.doesCodingListMatch(codings));
    }

    @Test
    public void whenParamListHasNoMatchingCodingsForCodingList_doesCodingListMatch_shouldBeFalse() {
        TokenOrListParam params = new TokenOrListParam();
        params.add("http://foo.org", "53");
        params.add("http://bar.org", "52");

        List<CodingDt> codings = new ArrayList<CodingDt>();
        codings.add(new CodingDt("http://baz.org", "53"));
        codings.add(new CodingDt("http://bar.org", "11"));

        assertFalse(params.doesCodingListMatch(codings));
    }
}
