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.transform; 019 020import org.fcrepo.transform.transformations.LDPathTransform; 021import org.fcrepo.transform.transformations.SparqlQueryTransform; 022import org.junit.Before; 023import org.junit.Test; 024import org.mockito.Mock; 025 026import javax.ws.rs.core.MediaType; 027 028import java.io.InputStream; 029import java.util.Collection; 030import java.util.Map; 031 032import static org.apache.jena.riot.WebContent.contentTypeSPARQLQuery; 033import static org.fcrepo.transform.transformations.LDPathTransform.APPLICATION_RDF_LDPATH; 034import static org.junit.Assert.assertEquals; 035import static org.mockito.MockitoAnnotations.initMocks; 036 037/** 038 * <p>TransformationFactoryTest class.</p> 039 * 040 * @author cbeer 041 */ 042public class TransformationFactoryTest { 043 044 @Mock 045 InputStream mockInputStream; 046 047 TransformationFactory transformationFactory; 048 049 @Before 050 public void setUp() { 051 initMocks(this); 052 transformationFactory = new TransformationFactory(); 053 } 054 055 @Test 056 public void testLDPathCreation() { 057 058 final Transformation<Map<String, Collection<Object>>> transform = 059 transformationFactory.getTransform(MediaType.valueOf(APPLICATION_RDF_LDPATH), mockInputStream); 060 061 assertEquals(new LDPathTransform(mockInputStream), transform); 062 063 } 064 065 @Test 066 public void testSparqlCreation() { 067 068 final Transformation<Map<String, Collection<Object>>> transform = 069 transformationFactory.getTransform(MediaType.valueOf(contentTypeSPARQLQuery), mockInputStream); 070 assertEquals(new SparqlQueryTransform(mockInputStream), transform); 071 072 } 073 074 075 @Test(expected = UnsupportedOperationException.class) 076 public void testOtherCreation() { 077 078 transformationFactory.getTransform(MediaType.valueOf("some/mime-type"), mockInputStream); 079 080 } 081}