Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License"). You may not
   * use this file except in compliance with the License. A copy of the License is
   * located at
   * 
   * http://aws.amazon.com/apache2.0
   * 
  * or in the "license" file accompanying this file. This file 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.amazonaws.services.simpleworkflow.flow.junit;
 
 import  org.junit.Assert;
 
Similar to Assert which waits on Promise argument before calling correspondent Assert... function.

To avoid overload conflicts "WaitFor" postfix is used for methods that define varargs "waitFor" argument.

For example when AsyncAssert.assertEquals("expected", "expected", waitForMe) is called Java resolves it to void assertEquals(final String message, final Object expected, final Promise<?> actual) when void assertEquals(final Object expected, final Object actual, Promise<?>... waitFor) was assumed.

See also:
Assert
 
 public class AsyncAssert {
 
     protected AsyncAssert() {
     }
 
     static public void assertReady(String messagePromise<?> condition) {
         Assert.assertTrue(messagecondition.isReady());
     }
 
     static public void assertReady(Promise<?> condition) {
         Assert.assertTrue(condition.isReady());
     }
 
     static public void assertNotReady(String messagePromise<?> condition) {
         Assert.assertFalse(messagecondition.isReady());
     }
 
     static public void assertNotReady(Promise<?> condition) {
         Assert.assertFalse(condition.isReady());
     }
 
     static public void assertTrueWaitFor(final String messagefinal boolean condition, Promise<?>... waitFor) {
         new Task(waitFor) {
 
             @Override
             protected void doExecute() throws Throwable {
                 Assert.assertTrue(messagecondition);
             }
         };
     }
 
     static public void assertTrue(final String messagefinal Promise<Booleancondition) {
         new Task(condition) {
 
             @Override
             protected void doExecute() throws Throwable {
                 Assert.assertTrue(messagecondition.get());
             }
         };
     }
 
     static public void assertTrueWaitFor(final boolean condition, Promise<?>... waitFor) {
         new Task(waitFor) {
 
             @Override
             protected void doExecute() throws Throwable {
                 Assert.assertTrue(condition);
             }
         };
     }
 
     static public void assertTrue(final Promise<Booleancondition) {
         new Task(condition) {
 
             @Override
             protected void doExecute() throws Throwable {
                 Assert.assertTrue(condition.get());
             }
         };
     }
 
    static public void assertFalseWaitFor(final String messagefinal boolean condition, Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertFalse(messagecondition);
            }
        };
    }
    static public void assertFalse(final String messagefinal Promise<Booleancondition) {
        new Task(condition) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertFalse(messagecondition.get());
            }
        };
    }
    static public void assertFalseWaitFor(final boolean condition, Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertFalse(condition);
            }
        };
    }
    static public void assertFalse(final Promise<Booleancondition) {
        new Task(condition) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertFalse(condition.get());
            }
        };
    }
    static public void assertEquals(final String messagefinal Object expectedfinal Promise<?> actual) {
        new Task(actual) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertEquals(messageexpectedactual.get());
            }
        };
    }
    static public void assertEqualsWaitFor(final String messagefinal Object expectedfinal Object actual,
            Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertEquals(messageexpectedactual);
            }
        };
    }
    static public void assertEquals(final Object expectedfinal Promise<?> actual) {
        new Task(actual) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertEquals(expectedactual.get());
            }
        };
    }
    static public void assertEqualsWaitFor(final Object expectedfinal Object actual, Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertEquals(expectedactual);
            }
        };
    }
    public static void assertArrayEquals(final String messagefinal Object[] expectedfinal Object[] actual,
            Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertArrayEquals(messageexpectedactual);
            }
        };
    }
    public static void assertArrayEquals(final String messagefinal Object[] expectedfinal Promise<Object[]> actual) {
        new Task(actual) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertArrayEquals(messageexpectedactual.get());
            }
        };
    }
    public static void assertArrayEqualsWaitFor(final Object[] expectedfinal Object[] actual, Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertArrayEquals(expectedactual);
            }
        };
    }
    public static void assertArrayEquals(final Object[] expectedfinal Promise<Object[]> actual) {
        new Task(actual) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertArrayEquals(expectedactual.get());
            }
        };
    }
    static public void assertEqualsWaitFor(final String messagefinal double expectedfinal double actualfinal double delta,
            Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertEquals(messageexpectedactualdelta);
            }
        };
    }
    static public void assertEquals(final String messagefinal double expectedfinal Promise<Doubleactualfinal double delta) {
        new Task(actual) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertEquals(messageexpectedactual.get(), delta);
            }
        };
    }
    static public void assertEqualsWaitFor(final double expectedfinal double actualfinal double delta, Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertEquals(expectedactualdelta);
            }
        };
    }
    static public void assertEquals(final double expectedfinal Promise<Doubleactualfinal double delta) {
        new Task(actual) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertEquals(expectedactual.get(), delta);
            }
        };
    }
    static public void assertNotNullWaitFor(final String messagefinal Object object, Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertNotNull(messageobject);
            }
        };
    }

    
Asserts that an object Promise and its content isn't null. If it is an AssertionError is thrown with the given message.

Parameters:
message the identifying message for the AssertionError ( null okay)
object Object to check or null
    static public void assertNotNull(final String messagefinal Promise<Objectobject) {
        Assert.assertNotNull(messageobject);
        new Task(object) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertNotNull(messageobject.get());
            }
        };
    }
    static public void assertNotNullWaitFor(final Object object, Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertNotNull(object);
            }
        };
    }

    
Asserts that an object its content isn't null.
    static public void assertNotNull(final Promise<Objectobject) {
        Assert.assertNotNull(object);
        new Task(object) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertNotNull(object.get());
            }
        };
    }
    static public void assertNullWaitFor(final String messagefinal Object object, Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertNull(messageobject);
            }
        };
    }

    
Asserts that an object is not null while object.get() is null.
    static public void assertNull(final String messagefinal Promise<Objectobject) {
        Assert.assertNotNull(object);
        new Task(object) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertNull(messageobject.get());
            }
        };
    }
    static public void assertNullWaitFor(final Object object, Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertNull(object);
            }
        };
    }

    
Asserts that an object is not null while object.get() is null.
    static public void assertNull(final Promise<Objectobject) {
        Assert.assertNotNull(object);
        new Task(object) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertNull(object.get());
            }
        };
    }
    static public void assertSameWaitFor(final String messagefinal Object expectedfinal Object actual, Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertSame(messageexpectedactual);
            }
        };
    }

    
Asserts that two Promises content refer to the same object. If they are not, an AssertionError is thrown with the given message.
    static public void assertSame(final String messagefinal Object expectedfinal Promise<Objectactual) {
        new Task(actual) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertSame(messageexpectedactual.get());
            }
        };
    }
    static public void assertSameWaitFor(final Object expectedfinal Object actual, Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertSame(expectedactual);
            }
        };
    }

    
Asserts that two Promises content refer to the same object. If they are not, an AssertionError is thrown with the given message.
    static public void assertSame(final Object expectedfinal Promise<Objectactual) {
        new Task(actual) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertSame(expectedactual.get());
            }
        };
    }
    static public void assertNotSameWaitFor(final String messagefinal Object expectedfinal Object actual,
            Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertNotSame(messageexpectedactual);
            }
        };
    }

    
Asserts that two Promises content do not refer to the same object. If they are an AssertionError is thrown with the given message.
    static public void assertNotSame(final String messagefinal Object expectedfinal Promise<Objectactual) {
        new Task(actual) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertNotSame(messageexpectedactual.get());
            }
        };
    }
    static public void assertNotSameWaitFor(final Object expectedfinal Object actual, Promise<?>... waitFor) {
        new Task(waitFor) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertNotSame(expectedactual);
            }
        };
    }

    
Asserts that two Promises content do not refer to the same object. If they are an AssertionError is thrown with the given message.
    static public void assertNotSame(final Object expectedfinal Promise<Objectactual) {
        new Task(actual) {
            @Override
            protected void doExecute() throws Throwable {
                Assert.assertNotSame(expectedactual.get());
            }
        };
    }
New to GrepCode? Check out our FAQ X