package uk.gov.register.resources.v2;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
import uk.gov.register.views.representations.ExtraMediaType;

import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.lang.reflect.Method;
import java.util.List;

import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.*;

@RunWith(MockitoJUnitRunner.class)
public class EntryResourceTest {
    @Test
    public void findByEntryNumberAvailableInV2() throws Exception {
        Method findBySerialMethod = EntryResource.class.getDeclaredMethod("findByEntryNumber", int.class);
        List<String> declaredMediaTypes = asList(findBySerialMethod.getDeclaredAnnotation(Produces.class).value());

        assertThat(declaredMediaTypes,
                hasItems(MediaType.APPLICATION_JSON,
                        ExtraMediaType.TEXT_CSV));
    }
}

@@ -456,16 +456,57 @@
 sItems;%0A
+import static org.hamcrest.Matchers.not;%0A
 import s
@@ -1050,11 +1050,655 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void v2DropsSupportForContentTypes() throws Exception %7B%0A        Method findBySerialMethod = EntryResource.class.getDeclaredMethod(%22findByEntryNumber%22, int.class);%0A        List%3CString%3E declaredMediaTypes = asList(findBySerialMethod.getDeclaredAnnotation(Produces.class).value());%0A%0A        assertThat(declaredMediaTypes, not(hasItems(ExtraMediaType.TEXT_YAML)));%0A        assertThat(declaredMediaTypes, not(hasItems(ExtraMediaType.APPLICATION_SPREADSHEET)));%0A        assertThat(declaredMediaTypes, not(hasItems(ExtraMediaType.TEXT_TSV)));%0A        assertThat(declaredMediaTypes, not(hasItems(ExtraMediaType.TEXT_TTL)));%0A    %7D
 %0A%7D%0A

Test that V2 API removes old content types