001/* 002 * The contents of this file are subject to the license and copyright 003 * detailed in the LICENSE and NOTICE files at the root of the source 004 * tree. 005 */ 006package org.fcrepo.http.commons.exceptionhandlers; 007 008import static org.junit.Assert.assertEquals; 009import javax.ws.rs.core.Response; 010import static javax.ws.rs.core.Response.Status.BAD_REQUEST; 011import static javax.ws.rs.core.HttpHeaders.CONTENT_TYPE; 012import static org.fcrepo.http.commons.domain.RDFMediaType.TEXT_PLAIN_WITH_CHARSET; 013 014import org.fcrepo.kernel.api.exception.FedoraInvalidNamespaceException; 015 016import org.junit.Before; 017import org.junit.Test; 018 019/** 020 * <p> 021 * FedoraInvalidNamespaceExceptionMapperTest class. 022 * </p> 023 * 024 * @author Daniel Bernstein 025 * @since January 19, 2017 026 */ 027public class FedoraInvalidNamespaceExceptionMapperTest { 028 029 private FedoraInvalidNamespaceExceptionMapper testObj; 030 031 @Before 032 public void setUp() { 033 testObj = new FedoraInvalidNamespaceExceptionMapper(); 034 } 035 036 @Test 037 public void testToResponse() { 038 final FedoraInvalidNamespaceException input = new FedoraInvalidNamespaceException( 039 "Invalid namespace", null); 040 final Response actual = testObj.toResponse(input); 041 assertEquals(BAD_REQUEST.getStatusCode(), actual.getStatus()); 042 assertEquals(TEXT_PLAIN_WITH_CHARSET, actual.getHeaderString(CONTENT_TYPE)); 043 044 } 045}