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