/*
 * Copyright 2015 Adam Bien.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License 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.airhacks.breakr;

/*
 * #%L
 * breakr
 * %%
 * Copyright (C) 2015 Adam Bien
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License 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.
 * #L%
 */
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;

/**
 *
 * @author airhacks.com
 */
public class CircuitTest {

    Circuit cut;

    @Before
    public void init() {
        this.cut = new Circuit();
        this.cut.init();
    }

    @Test
    public void exceptionExcalation() {
        this.cut.newException(null);
        boolean open = this.cut.isOpen(1);
        assertFalse(open);

        this.cut.newException(null);
        open = this.cut.isOpen(1);
        assertTrue(open);

        this.cut.reset();

        open = this.cut.isOpen(1);
        assertFalse(open);
    }

    @Test
    public void timeoutExcalation() {
        this.cut.newTimeout(0);
        boolean open = this.cut.isOpen(1);
        assertFalse(open);

        this.cut.newTimeout(0);
        open = this.cut.isOpen(1);
        assertTrue(open);

        this.cut.reset();

        open = this.cut.isOpen(1);
        assertFalse(open);
    }

}

@@ -1613,32 +1613,73 @@
 nExcalation() %7B%0A
+        assertFalse(this.cut.isOpen(1));%0A
         this.cut
@@ -1748,36 +1748,35 @@
 ;%0A        assert
-Fals
+Tru
 e(open);%0A%0A      
@@ -2024,99 +2024,110 @@
     
-this.cut.newTimeout(0);%0A        boolean open = this.cut.isOpen(1);%0A        assertFalse(open
+assertFalse(this.cut.isOpen(1));%0A        this.cut.newTimeout(0);%0A        assertTrue(this.cut.isOpen(1)
 );%0A%0A
@@ -2158,39 +2158,43 @@
 out(0);%0A        
-open = 
+assertTrue(
 this.cut.isOpen(
@@ -2199,33 +2199,8 @@
 n(1)
-;%0A        assertTrue(open
 );%0A%0A
@@ -2225,39 +2225,32 @@
 eset();%0A%0A       
- open =
  this.cut.isOpen
@@ -2266,32 +2266,46 @@
     assertFalse(
-open
+this.cut.isOpen(1)
 );%0A    %7D%0A%0A%7D%0A

Test refactored