/**
 * The MIT License
 * Copyright (c) 2014-2016 Ilkka Seppälä
 * <p>
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * <p>
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * <p>
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package com.iluwatar.dependency.injection;

import com.iluwatar.dependency.injection.utils.InMemoryAppender;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class AdvancedSorceressTest {

    private InMemoryAppender appender;

    @Before
    public void setUp() {
        appender = new InMemoryAppender(Tobacco.class);
    }

    @After
    public void tearDown() {
        appender.stop();
    }

    /**
     * Test if the {@link AdvancedSorceress} smokes whatever instance of {@link Tobacco} is passed to her
     * through the setter's parameter
     */
    
    @Test
    public void testSmokeEveryThing() throws Exception {

        final Tobacco[] tobaccos = {
                new OldTobyTobacco(), new RivendellTobacco(), new SecondBreakfastTobacco()
        };

        for (final Tobacco tobacco : tobaccos) {
            final AdvancedSorceress advancedSorceress = new AdvancedSorceress();
            advancedSorceress.setTobacco(tobacco);
            advancedSorceress.smoke();
            // Verify if the sorceress is smoking the correct tobacco ...
            assertEquals("AdvancedSorceress smoking " + tobacco.getClass().getSimpleName(), appender.getLastMessage());

        }

        // ... and nothing else is happening.
        assertEquals(tobaccos.length, appender.getLogSize());
    }
}

@@ -1357,16 +1357,18 @@
 .Test;%0D%0A
+%0D%0A
 import s
@@ -1407,16 +1407,91 @@
 als;%0D%0A%0D%0A
+/**%0D%0A * Date: 28/04/17 - 7:40 AM%0D%0A *%0D%0A * @author Stanislav Kapinus%0D%0A */%0D%0A%0D%0A
 public c
@@ -1522,18 +1522,16 @@
 st %7B%0D%0A%0D%0A
-  
   privat
@@ -1562,18 +1562,16 @@
 der;%0D%0A%0D%0A
-  
   @Befor
@@ -1571,26 +1571,24 @@
  @Before%0D%0A  
- 
- 
 public void 
@@ -1594,28 +1594,24 @@
  setUp() %7B%0D%0A
-    
     appender
@@ -1647,26 +1647,24 @@
 co.class);%0D%0A
-  
   %7D%0D%0A%0D%0A    @
@@ -1664,18 +1664,16 @@
 %0D%0A  
- 
- 
 @After%0D%0A
     
@@ -1668,18 +1668,16 @@
 @After%0D%0A
-  
   public
@@ -1692,28 +1692,24 @@
 arDown() %7B%0D%0A
-    
     appender
@@ -1724,26 +1724,20 @@
 %0D%0A  
- 
- 
 %7D%0D%0A%0D%0A
-  
   /**%0D%0A
-  
    *
@@ -1840,18 +1840,16 @@
 her%0D%0A   
-  
 * throug
@@ -1881,22 +1881,12 @@
 %0A   
-  
 */%0D%0A
-    %0D%0A  
   @T
@@ -1892,18 +1892,16 @@
 Test%0D%0A  
- 
- 
 public v
@@ -1944,28 +1944,24 @@
 eption %7B%0D%0A%0D%0A
-    
     final To
@@ -1990,24 +1990,16 @@
         
-      
-  
 new OldT
@@ -2066,20 +2066,16 @@
 acco()%0D%0A
-    
     %7D;%0D%0A
@@ -2072,28 +2072,24 @@
 %0D%0A    %7D;%0D%0A%0D%0A
-    
     for (fin
@@ -2128,22 +2128,16 @@
 %0D%0A      
- 
-     
 final Ad
@@ -2194,30 +2194,24 @@
 rceress();%0D%0A
-      
       advanc
@@ -2250,22 +2250,16 @@
 %0D%0A      
- 
-     
 advanced
@@ -2278,22 +2278,16 @@
 oke();%0D%0A
-      
       //
@@ -2347,22 +2347,16 @@
 co ...%0D%0A
-      
       as
@@ -2460,28 +2460,24 @@
 sage());%0D%0A%0D%0A
-    
     %7D%0D%0A%0D%0A   
@@ -2477,20 +2477,16 @@
 %0D%0A%0D%0A    
- 
-   
 // ... a
@@ -2516,20 +2516,16 @@
 ening.%0D%0A
-    
     asse
@@ -2575,18 +2575,18 @@
 ze());%0D%0A
-  
+%0D%0A
   %7D%0D%0A%7D%0D%0A

Update AdvancedSorceressTest.java