/*
 * Licensed to Crate under one or more contributor license agreements.
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.  Crate licenses this file
 * to you 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.
 *
 * However, if you have executed another commercial license agreement
 * with Crate these terms will supersede the license and you may use the
 * software solely pursuant to the terms of the relevant commercial
 * agreement.
 */

package io.crate.testing;

import org.hamcrest.Matcher;
import org.junit.jupiter.api.function.Executable;
import org.opentest4j.AssertionFailedError;

public class Asserts {

    private Asserts() {}

    public static <T extends Throwable> void assertThrows(Executable executable, Matcher<T> matcher) {
        try {
            executable.execute();
        } catch (Throwable t) {
            if (matcher.matches(t)) {
                return;
            }
            throw new AssertionFailedError(
                String.format("Unmatched %s type thrown with message '%s'",
                              t.getClass().getCanonicalName(),
                              t.getMessage()), t);
        }
        throw new AssertionFailedError("Expected exception to be thrown, but nothing was thrown.");
    }
}

@@ -1022,24 +1022,31 @@
 ng;%0A%0Aimport 
+static 
 org.hamcrest
@@ -1053,16 +1053,104 @@
 .Matcher
+Assert.assertThat;%0A%0Aimport org.hamcrest.Matcher;%0Aimport org.junit.jupiter.api.Assertions
 ;%0Aimport
@@ -1196,52 +1196,8 @@
 ble;
-%0Aimport org.opentest4j.AssertionFailedError;
 %0A%0Apu
@@ -1265,30 +1265,8 @@
 atic
- %3CT extends Throwable%3E
  voi
@@ -1311,17 +1311,33 @@
 Matcher%3C
-T
+? super Throwable
 %3E matche
@@ -1401,349 +1401,128 @@
     
-%7D catch (Throwable t) %7B%0A            if (matcher.matches(t)) %7B%0A                return;%0A            %7D%0A            throw new AssertionFailedError(%0A                String.format(%22Unmatched %25s type thrown with message '%25s'%22,%0A                              t.getClass().getCanonicalName(),%0A                              t.getMessage()), t);
+    Assertions.fail(%22Expected exception to be thrown, but nothing was thrown.%22);%0A        %7D catch (Throwable t) %7B
 %0A       
  %7D%0A 
@@ -1521,110 +1521,46 @@
     
- %7D%0A
      
-   throw new AssertionFailedError(%22Expected exception to be thrown, but nothing was thrown.%22);
+assertThat(t, matcher);%0A        %7D
 %0A   

Use junit assertions in assertThrows