/*-
 * -\-\-
 * Spotify styx
 * --
 * Copyright (C) 2018 Spotify AB
 * --
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * -/-/-
 */

package com.spotify.styx.util;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class ClassEnforcerTest {

  @Rule public ExpectedException exception = ExpectedException.none();

  @Test
  public void shouldAssertNotInstantiable() throws ReflectiveOperationException {
    ClassEnforcer.assertNotInstantiable(ClassEnforcer.class);
  }

  @Test
  public void shouldAssertInstantiable() throws ReflectiveOperationException {
    exception.expect(AssertionError.class);
    exception.expectMessage("Class should not be instantiable: " + String.class.getName());
    ClassEnforcer.assertNotInstantiable(String.class);
  }

  @Test
  public void shouldAssertNotInstantiablWithoutDefaultConstructor()
      throws ReflectiveOperationException {
    exception.expect(NoSuchMethodException.class);
    ClassEnforcer.assertNotInstantiable(Class.class);
  }
}

@@ -1015,32 +1015,390 @@
 er.class);%0A  %7D%0A%0A
+  @Test%0A  public void shouldAssertNotInstantiableConstructorThrowsUnsupportedOperationException() throws ReflectiveOperationException %7B%0A    exception.expect(AssertionError.class);%0A    exception.expectMessage(%22Class should not be instantiable: %22 + FailingInstantiable.class.getName());%0A    ClassEnforcer.assertNotInstantiable(FailingInstantiable.class);%0A  %7D%0A%0A
   @Test%0A  public
@@ -1892,11 +1892,143 @@
 ss);%0A  %7D
+%0A%0A  private static class FailingInstantiable %7B%0A%0A    public FailingInstantiable() %7B%0A      throw new NullPointerException();%0A    %7D%0A  %7D
 %0A%7D%0A

add test