package com.bugsnag.android;

import com.bugsnag.android.BeforeNotify;
import com.bugsnag.android.Error;

public class BeforeNotifyTest extends BugsnagTestCase {
    BeforeNotify beforeNotify = new BeforeNotify() {
        @Override
        public boolean run(Error error) {
            return true;
        }
    };

    BeforeNotify beforeNotifySkip = new BeforeNotify() {
        @Override
        public boolean run(Error error) {
            return false;
        }
    };

    @Override
    protected void setUp() {

    }

    public void testRunModifiesError() {
        BeforeNotify beforeNotify = new BeforeNotify() {
            @Override
            public boolean run(Error error) {
                error.setContext("new-context");
                return false;
            }
        };

        Configuration config = new Configuration("api-key");
        Error error = new Error(config, new RuntimeException("Test"));
        beforeNotify.run(error);

        assertEquals(error.getContext(), "new-context");
    }

    public void testRunAll() {
        // Any false beforeNotify should return false
        Configuration config = new Configuration("api-key");
        config.addBeforeNotify(beforeNotify);
        config.addBeforeNotify(beforeNotifySkip);

        Error error = new Error(config, new RuntimeException("Test"));
        assertFalse(BeforeNotify.runAll(config.beforeNotifyTasks, error));
    }
}

@@ -476,59 +476,8 @@
 %7D;%0A%0A
-    @Override%0A    protected void setUp() %7B%0A%0A    %7D%0A%0A
     

Remove dead code