package com.bugsnag.android;

import android.test.AndroidTestCase;

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

public class ConfigurationTest extends AndroidTestCase {
    @Override
    protected void setUp() {

    }

    public void testEndpoints() {
        Configuration config = new Configuration("api-key");

        // Default endpoints
        assertEquals(config.getNotifyEndpoint(), "http://notify.bugsnag.com");
        assertEquals(config.getMetricsEndpoint(), "http://notify.bugsnag.com/metrics");

        // Setting an endpoint
        config.endpoint = "http://localhost:8000";
        assertEquals(config.getNotifyEndpoint(), "http://localhost:8000");
        assertEquals(config.getMetricsEndpoint(), "http://localhost:8000/metrics");
    }

    public void testShouldNotify() {
        Configuration config = new Configuration("api-key");

        // Should notify if notifyReleaseStages is null
        assertTrue(config.shouldNotify());

        // Shouldn't notify if notifyReleaseStages is set and releaseStage is null
        config.notifyReleaseStages = new String[] {"example"};
        assertFalse(config.shouldNotify());

        // Shouldn't notify if releaseStage not in notifyReleaseStages
        config.notifyReleaseStages = new String[] {"production"};
        config.releaseStage = "not-production";
        assertFalse(config.shouldNotify());

        // Should notify if releaseStage in notifyReleaseStages
        config.notifyReleaseStages = new String[] {"production"};
        config.releaseStage = "production";
        assertTrue(config.shouldNotify());
    }

    public void testShouldIgnore() {
        Configuration config = new Configuration("api-key");

        // Should not ignore by default
        assertFalse(config.shouldIgnore("java.io.IOException"));

        // Should ignore when added to ignoreClasses
        config.ignoreClasses = new String[] {"java.io.IOException"};
        assertTrue(config.shouldIgnore("java.io.IOException"));
    }

    public void testBeforeNotify() {
        Configuration config = new Configuration("api-key");
        BeforeNotify beforeNotify = new BeforeNotify() {
            @Override
            public boolean run(Error error) {
                return false;
            }
        };



        // Should not ignore by default
        assertFalse(config.shouldIgnore("java.io.IOException"));

        // Should ignore when added to ignoreClasses
        config.ignoreClasses = new String[] {"java.io.IOException"};
        assertTrue(config.shouldIgnore("java.io.IOException"));
    }
}

@@ -2090,28 +2090,25 @@
 oid test
-BeforeNotify
+InProject
 () %7B%0A   
@@ -2165,24 +2165,25 @@
 -key%22);%0A
+%0A
         
 BeforeNo
@@ -2178,222 +2178,269 @@
     
-BeforeNotify beforeNotify = new BeforeNotify() %7B%0A            @Override%0A            public boolean run(Error error) %7B%0A                return false;%0A            %7D%0A        %7D;%0A%0A%0A%0A        // Should not ignore by default
+// Shouldn't be inProject if projectPackages hasn't been set%0A        assertFalse(config.inProject(%22com.bugsnag.android.Example%22));%0A%0A        // Should be inProject if class in projectPackages%0A        config.projectPackages = new String%5B%5D %7B%22com.bugsnag.android%22%7D;
 %0A   
@@ -2442,36 +2442,35 @@
 ;%0A        assert
-Fals
+Tru
 e(config.shouldI
@@ -2466,97 +2466,115 @@
 fig.
-shouldIgnore(%22java.io.IOException%22));%0A%0A        // Should ignore when added to ignoreClass
+inProject(%22com.bugsnag.android.Example%22));%0A%0A        // Shouldn't be inProject if class not in projectPackag
 es%0A 
@@ -2583,35 +2583,37 @@
      config.
-ignoreClass
+projectPackag
 es = new Str
@@ -2620,35 +2620,35 @@
 ing%5B%5D %7B%22
-java.io.IOException
+com.bugsnag.android
 %22%7D;%0A    
@@ -2649,35 +2649,36 @@
 ;%0A        assert
-Tru
+Fals
 e(config.shouldI
@@ -2666,36 +2666,33 @@
 alse(config.
-shouldIgnore
+inProject
 (%22java.io.IO

Add inProject tests