/*
 * Copyright 2015-2016 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v10.html
 */

package extensions;

import org.junit.gen5.api.Assertions;
import org.junit.gen5.api.extension.AfterEachExtensionPoint;
import org.junit.gen5.api.extension.ExceptionHandlerExtensionPoint;
import org.junit.gen5.api.extension.ExtensionContext.Namespace;
import org.junit.gen5.api.extension.ExtensionContext.Store;
import org.junit.gen5.api.extension.TestExtensionContext;
import org.opentest4j.AssertionFailedError;

public class ExpectToFailExtension implements ExceptionHandlerExtensionPoint, AfterEachExtensionPoint {

	@Override
	public void handleException(TestExtensionContext context, Throwable throwable) throws Throwable {
		if (throwable instanceof AssertionFailedError) {
			getExceptionStore(context).put("exception", throwable);
			return;
		}
		throw throwable;
	}

	private Store getExceptionStore(TestExtensionContext context) {
		return context.getStore(Namespace.of(context));
	}

	@Override
	public void afterEach(TestExtensionContext context) throws Exception {
		if (getExceptionStore(context).get("exception") == null)
			Assertions.fail("Test should have failed");
	}
}

@@ -327,32 +327,39 @@
 nsions;%0A%0Aimport 
+static 
 org.junit.gen5.a
@@ -371,17 +371,32 @@
 sertions
-;
+.assertNotNull;%0A
 %0Aimport 
@@ -1111,127 +1111,8 @@
 %09%7D%0A%0A
-%09private Store getExceptionStore(TestExtensionContext context) %7B%0A%09%09return context.getStore(Namespace.of(context));%0A%09%7D%0A%0A
 %09@Ov
@@ -1192,19 +1192,29 @@
 ion %7B%0A%09%09
-if 
+assertNotNull
 (getExce
@@ -1253,62 +1253,154 @@
 on%22)
- == null)%0A%09%09%09Assertions.fail(%22Test should have failed%22
+, %22Test should have failed%22);%0A%09%7D%0A%0A%09private Store getExceptionStore(TestExtensionContext context) %7B%0A%09%09return context.getStore(Namespace.of(context)
 );%0A%09

Use assertNotNull instead of `if`