fix #22
[storage-units.git] / storage-units / src / test / java / de / xn__ho_hia / storage_unit / StorageUnitsTest.java
blob64b7a77a3ee386bd63e4c93c3cff6e4f61a042af
1 /*
2 * This file is part of storage-units. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at http://creativecommons.org/publicdomain/zero/1.0/. No part of storage-units,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
5 * in the LICENSE file.
6 */
7 package de.xn__ho_hia.storage_unit;
9 import java.lang.reflect.Constructor;
10 import java.lang.reflect.InvocationTargetException;
11 import java.lang.reflect.Modifier;
13 import org.junit.Assert;
14 import org.junit.Test;
16 import de.xn__ho_hia.quality.suppression.CompilerWarnings;
17 import de.xn__ho_hia.storage_unit.StorageUnits;
19 /**
20 * General test cases for the {@link StorageUnits} class.
22 public class StorageUnitsTest {
24 /**
25 * Ensures that the constructor of the {@link StorageUnits} class is private.
26 * <p>
27 * The class should never be instantiated. Instead use the static factory methods to construct storage units.
29 * @throws NoSuchMethodException
30 * Should not fail in case the StorageUnits class has a constructor..
31 * @throws IllegalAccessException
32 * Should not fail in case the StorageUnits class has a constructor..
33 * @throws InvocationTargetException
34 * Should not fail in case the StorageUnits class has a constructor..
35 * @throws InstantiationException
36 * Should not fail in case the StorageUnits class has a constructor..
38 @Test
39 @SuppressWarnings({ CompilerWarnings.NLS, CompilerWarnings.STATIC_METHOD })
40 public void shouldDeclarePrivateConstructor()
41 throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
42 // Given
43 final Constructor<StorageUnits> constructor = StorageUnits.class.getDeclaredConstructor();
45 // When
46 final boolean isPrivate = Modifier.isPrivate(constructor.getModifiers());
48 // Then
49 Assert.assertTrue("Constructor is not private", isPrivate);
50 constructor.setAccessible(true);
51 constructor.newInstance();