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