1 package net.sf.openrocket.preset;
3 import static org.junit.Assert.*;
5 public abstract class PresetAssertHelper {
7 public static void assertInvalidPresetException( InvalidComponentPresetException exceptions, TypedKey<?>[] keys, String[] messages ) {
9 assertEquals( keys.length, exceptions.getInvalidParameters().size() );
10 for( TypedKey<?> expectedKey : keys ) {
11 boolean keyFound = false;
12 for( TypedKey<?> k : exceptions.getInvalidParameters() ) {
13 if ( expectedKey == k ) {
19 fail( "Expected key " + expectedKey + " not in exception");
23 assertEquals(0, exceptions.getInvalidParameters().size() );
25 if ( messages != null ) {
26 assertEquals( messages.length, exceptions.getErrors().size() );
27 for( String expectedMessage : messages ) {
28 boolean stringMatched = false;
29 for ( String s : exceptions.getErrors() ) {
30 if ( s.contains( expectedMessage ) ) {
35 if( !stringMatched ) {
36 fail( "Expected string \"" + expectedMessage + "\" not reported in errors");
40 assertEquals(0, exceptions.getErrors().size() );