Ejemplo n.º 1
0
        //-------------------------------------------------------------------------
        public virtual void test_of_reasonMessageException()
        {
            System.ArgumentException ex = new System.ArgumentException("exmsg");
            FailureItem test            = FailureItem.of(FailureReason.INVALID, ex, "my failure");

            assertEquals(test.Reason, FailureReason.INVALID);
            assertEquals(test.Message, "my failure");
            assertTrue(test.CauseType.Present);
            assertEquals(test.CauseType.get(), typeof(System.ArgumentException));
            assertTrue(test.StackTrace.Contains(".test_of_reasonMessageException("));
            assertEquals(test.ToString(), "INVALID: my failure: java.lang.IllegalArgumentException: exmsg");
        }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------
        public virtual void test_of_reasonMessage()
        {
            FailureItem test = FailureItem.of(FailureReason.INVALID, "my {} {} failure", "big", "bad");

            assertEquals(test.Reason, FailureReason.INVALID);
            assertEquals(test.Message, "my big bad failure");
            assertFalse(test.CauseType.Present);
            assertFalse(test.StackTrace.Contains(".FailureItem.of("));
            assertFalse(test.StackTrace.Contains(".Failure.of("));
            assertTrue(test.StackTrace.StartsWith("com.opengamma.strata.collect.result.FailureItem: my big bad failure", StringComparison.Ordinal));
            assertTrue(test.StackTrace.Contains(".test_of_reasonMessage("));
            assertEquals(test.ToString(), "INVALID: my big bad failure");
        }
Ejemplo n.º 3
0
        public virtual void test_of_reasonMessageExceptionNestedExceptionWithAttributes()
        {
            System.ArgumentException innerEx = new System.ArgumentException("inner");
            System.ArgumentException ex      = new System.ArgumentException("exmsg", innerEx);
            FailureItem test = FailureItem.of(FailureReason.INVALID, ex, "a {foo} {bar} failure", "big", "bad");

            assertEquals(test.Attributes, ImmutableMap.of("foo", "big", "bar", "bad", FailureItem.EXCEPTION_MESSAGE_ATTRIBUTE, "exmsg"));
            assertEquals(test.Reason, FailureReason.INVALID);
            assertEquals(test.Message, "a big bad failure");
            assertTrue(test.CauseType.Present);
            assertEquals(test.CauseType.get(), typeof(System.ArgumentException));
            assertTrue(test.StackTrace.Contains(".test_of_reasonMessageExceptionNestedExceptionWithAttributes("));
            assertEquals(test.ToString(), "INVALID: a big bad failure: java.lang.IllegalArgumentException: exmsg");
        }
Ejemplo n.º 4
0
        public virtual void test_withAttributes()
        {
            FailureItem test = FailureItem.of(FailureReason.INVALID, "my {one} {two} failure", "big", "bad");

            test = test.withAttributes(ImmutableMap.of("foo", "bar", "two", "good"));
            assertEquals(test.Attributes, ImmutableMap.of("one", "big", "two", "good", "foo", "bar"));
            assertEquals(test.Reason, FailureReason.INVALID);
            assertEquals(test.Message, "my big bad failure");
            assertFalse(test.CauseType.Present);
            assertFalse(test.StackTrace.Contains(".FailureItem.of("));
            assertFalse(test.StackTrace.Contains(".Failure.of("));
            assertTrue(test.StackTrace.StartsWith("com.opengamma.strata.collect.result.FailureItem: my big bad failure", StringComparison.Ordinal));
            assertTrue(test.StackTrace.Contains(".test_withAttributes("));
            assertEquals(test.ToString(), "INVALID: my big bad failure");
        }
Ejemplo n.º 5
0
        //-------------------------------------------------------------------------
        public virtual void generatedStackTrace_Failure()
        {
            Failure test = Failure.of(FailureReason.INVALID, "my {} {} failure", "big", "bad");

            assertEquals(test.Reason, FailureReason.INVALID);
            assertEquals(test.Message, "my big bad failure");
            assertEquals(test.Items.size(), 1);
            FailureItem item = test.Items.GetEnumerator().next();

            assertFalse(item.CauseType.Present);
            assertFalse(item.StackTrace.Contains(".FailureItem.of("));
            assertFalse(item.StackTrace.Contains(".Failure.of("));
            assertTrue(item.StackTrace.StartsWith("com.opengamma.strata.collect.result.FailureItem: my big bad failure", StringComparison.Ordinal));
            assertTrue(item.StackTrace.Contains(".generatedStackTrace_Failure("));
            assertEquals(item.ToString(), "INVALID: my big bad failure");
        }
Ejemplo n.º 6
0
        //-------------------------------------------------------------------------
        public virtual void test_of_reasonMessageShortStackTrace()
        {
            FailureItem test = FailureItem.meta().builder().set("reason", FailureReason.INVALID).set("message", "my issue").set("stackTrace", "Short stack trace").set("causeType", typeof(System.ArgumentException)).build();

            assertEquals(test.ToString(), "INVALID: my issue: Short stack trace");
        }