package uk.ac.ebi.quickgo.rest.search.results;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;

/**
 * Tests the implementation of the {@link Facet} implementation.
 */
public class FacetTest {
    @Rule
    public final ExpectedException thrown = ExpectedException.none();

    @Test
    public void newlyCreateFacetHasNoFacets() throws Exception {
        Facet facet = new Facet();

        assertThat(facet.getFacetFields(), is(empty()));
    }

    @Test
    public void addFacetField() throws Exception {
        FieldFacet fieldFacet1 = new FieldFacet("field1");
        FieldFacet fieldFacet2 = new FieldFacet("field2");
        FieldFacet fieldFacet3 = new FieldFacet("field3");

        Facet facet = new Facet();
        facet.addFacetField(fieldFacet1);
        facet.addFacetField(fieldFacet2);
        facet.addFacetField(fieldFacet3);

        assertThat(facet.getFacetFields(), hasSize(3));
        assertThat(facet.getFacetFields(), containsInAnyOrder(fieldFacet1, fieldFacet2, fieldFacet3));
    }

    @Test
    public void deletingFacetFieldThrowsException() throws Exception {
        FieldFacet fieldFacet1 = new FieldFacet("field1");

        thrown.expect(UnsupportedOperationException.class);

        Facet facet = new Facet();
        facet.addFacetField(fieldFacet1);

        facet.getFacetFields().remove(0);
    }
}
@@ -714,32 +714,355 @@
 pty()));%0A    %7D%0A%0A
+    @Test%0A    public void addingNullFacetFieldThrowsException() throws Exception %7B%0A        FieldFacet fieldFacet = null;%0A%0A        thrown.expect(IllegalArgumentException.class);%0A        thrown.expectMessage(%22Cannot add null field facet.%22);%0A%0A        Facet facet = new Facet();%0A        facet.addFacetField(fieldFacet);%0A    %7D%0A%0A
     @Test%0A    pu
@@ -1939,10 +1939,45 @@
 );%0A    %7D
+%0A%0A//    @Test%0A//    public void add
 %0A%7D

Add test to check if null field facet throws exception.