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.fcrepo.kernel.api.services.NodeService; 030 031import org.junit.Before; 032import org.junit.Test; 033import org.mockito.Mock; 034 035/** 036 * <p>AbstractResourceTest class.</p> 037 * 038 * @author awoods 039 */ 040public class AbstractResourceTest { 041 042 private AbstractResource testObj; 043 044 @Mock 045 private NodeService mockNodes; 046 047 @Mock 048 private Supplier<String> mockPids; 049 050 @Mock 051 private UriInfo mockUris; 052 053 @Mock 054 private HttpHeaders mockHeaders; 055 056 @Before 057 public void setUp() { 058 initMocks(this); 059 testObj = new AbstractResource() {/**/}; 060 } 061 062 @Test 063 public void testSetPidMinter() { 064 setField(testObj, "pidMinter", mockPids); 065 assertEquals(mockPids, testObj.pidMinter); 066 } 067 068 @Test 069 public void testSetNodeService() { 070 setField(testObj, "nodeService", mockNodes); 071 assertEquals(mockNodes, testObj.nodeService); 072 } 073 074 @Test 075 public void testSetUriInfo() { 076 setField(testObj, "uriInfo", mockUris); 077 assertEquals(mockUris, testObj.uriInfo); 078 } 079 080 @Test 081 public void testSetHeaders() { 082 setField(testObj, "headers", mockHeaders); 083 assertEquals(mockHeaders, testObj.headers); 084 } 085 086}