001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.http.commons; 019 020import static org.fcrepo.http.commons.test.util.TestHelpers.setField; 021import static org.junit.Assert.assertEquals; 022import static org.mockito.MockitoAnnotations.initMocks; 023 024import java.util.function.Supplier; 025 026import javax.ws.rs.core.HttpHeaders; 027import javax.ws.rs.core.UriInfo; 028 029import org.junit.Before; 030import org.junit.Test; 031import org.mockito.Mock; 032 033/** 034 * <p>AbstractResourceTest class.</p> 035 * 036 * @author awoods 037 */ 038public class AbstractResourceTest { 039 040 private AbstractResource testObj; 041 042 @Mock 043 private Supplier<String> mockPids; 044 045 @Mock 046 private UriInfo mockUris; 047 048 @Mock 049 private HttpHeaders mockHeaders; 050 051 @Before 052 public void setUp() { 053 initMocks(this); 054 testObj = new AbstractResource() {/**/}; 055 } 056 057 @Test 058 public void testSetPidMinter() { 059 setField(testObj, "pidMinter", mockPids); 060 assertEquals(mockPids, testObj.pidMinter); 061 } 062 063 @Test 064 public void testSetUriInfo() { 065 setField(testObj, "uriInfo", mockUris); 066 assertEquals(mockUris, testObj.uriInfo); 067 } 068 069 @Test 070 public void testSetHeaders() { 071 setField(testObj, "headers", mockHeaders); 072 assertEquals(mockHeaders, testObj.headers); 073 } 074 075}