@Test public void shouldRaiseRedlineExceptionWhenObjectCantBeResolved() { try { new PrimObject().resolveObject("Foo"); } catch (RedlineException e) { assertTrue(e.getCause() instanceof ClassNotFoundException); assertEquals("java.lang.ClassNotFoundException: Foo", e.getCause().toString()); } }
@Test public void shouldLookupImportsForFullyQualifiedClassNameWhenResolvingObjects() { PrimObject aClass = mock(PrimObject.class); PrimObject primObject = new PrimObject(); when(aClass.packageFor("Thing")).thenReturn("st.redline.Thing"); primObject.cls(aClass); try { primObject.resolveObject("Thing"); } catch (RedlineException e) { assertEquals( "st.redline.core.RedlineException: java.lang.ClassNotFoundException: st.redline.Thing", e.toString()); } }
@Test public void performShouldInvokeDnuWhenNoClassSet() { PrimObject object = new PrimObject(); try { object.perform("anything"); } catch (RedlineException e) { assertEquals( e.getMessage(), "Object '" + object.toString() + "' (" + object.cls().toString() + ") does not understand 'anything'."); } }