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.kernel.api.services.functions;
019
020import static org.junit.Assert.assertEquals;
021
022import org.junit.Test;
023
024/**
025 * <p>
026 * ConfigurableHierarchicalSupplierTest class.
027 * </p>
028 *
029 * @author rdfloyd
030 */
031public class ConfigurableHierarchicalSupplierTest {
032
033
034    @Test
035    public void testGet() {
036        final UniqueValueSupplier defaultPidMinter = new ConfigurableHierarchicalSupplier();
037        final String id = defaultPidMinter.get();
038        // No pairtrees is default; with no args check to see that id contains just the 1 pid part
039        final int parts = (id.split("/").length);
040        assertEquals(1, parts);
041    }
042
043    @Test
044    public void testGetIdNoPairtree() {
045        final UniqueValueSupplier defaultPidMinter = new ConfigurableHierarchicalSupplier(0, 0);
046        final String id = defaultPidMinter.get();
047        // With (desiredLength,desiredCount=0), check to see that id contains 1 part and no slashes
048        final int parts = (id.split("/").length);
049        assertEquals(1, parts);
050    }
051
052    @Test
053    public void testGetIdPairtreeParams() {
054        final UniqueValueSupplier defaultPidMinter = new ConfigurableHierarchicalSupplier(2, 4);
055        final String id = defaultPidMinter.get();
056        // With (desiredLength > 0 && desiredCount > 0) check to see that id contains (count + 1) parts
057        final int parts = (id.split("/").length);
058        assertEquals(5, parts);
059    }
060
061}