// Path: src/main/java/br/com/six2six/fixturefactory/transformer/Transformer.java
// public interface Transformer {
// 
//     <T> T transform(Object value, Class<T> type);
// 
//     boolean accepts(Object value, Class<?> type);
// }
// 
// Path: src/main/java/br/com/six2six/fixturefactory/transformer/TransformerChain.java
// public class TransformerChain {
// 
//     private Transformer transformer;
//     private TransformerChain next;
// 
//     public TransformerChain(Transformer transformer) {
//         this.transformer = transformer;
//     }
// 
//     public Object transform(Object value, Class<?> type) {
//         if (transformer.accepts(value, type)) {
//             value = transformer.transform(value, type);
//         } 
//         
//         if (next != null) {
//             value = next.transform(value, type);
//         }
// 
//         return value;
//     }
// 
//     public void add(Transformer transformer) {
//         if (this.next == null) {
//             this.next = new TransformerChain(transformer);
//         } else {
//             this.next.add(transformer);
//         }
//     }
// }


import static org.junit.Assert.assertEquals;
import org.junit.Test;
import br.com.six2six.fixturefactory.transformer.Transformer;
import br.com.six2six.fixturefactory.transformer.TransformerChain;
package br.com.six2six.fixturefactory.transformer;




public class TransformerChainTest {

    @Test
    public void shouldUseFirstTransformer() {
        TransformerChain transformerChain = new TransformerChain(new FirstTransformer());
        assertEquals("A1", transformerChain.transform("A", String.class));
    }
    
    @Test
    public void shouldUseSecondTransformer() {
        TransformerChain transformerChain = new TransformerChain(new FirstTransformer());
        transformerChain.add(new SecondTransformer());
        assertEquals("B2", transformerChain.transform("B", String.class));        
    }
    
    @Test
    public void shouldUseBothTransformersInOrderOfInclusion() {
        TransformerChain transformerChain = new TransformerChain(new FirstTransformer());
        transformerChain.add(new SecondTransformer());
        assertEquals("AB12", transformerChain.transform("AB", String.class));        
    }
    
    @Test
    public void shouldNotUseAnyOfTheTransformers() {
        TransformerChain transformerChain = new TransformerChain(new FirstTransformer());
        transformerChain.add(new SecondTransformer());
        assertEquals("C", transformerChain.transform("C", String.class));        
    }
}

// Path: src/main/java/br/com/six2six/fixturefactory/transformer/Transformer.java
// public interface Transformer {
// 
//     <T> T transform(Object value, Class<T> type);
// 
//     boolean accepts(Object value, Class<?> type);
// }
// 
// Path: src/main/java/br/com/six2six/fixturefactory/transformer/TransformerChain.java
// public class TransformerChain {
// 
//     private Transformer transformer;
//     private TransformerChain next;
// 
//     public TransformerChain(Transformer transformer) {
//         this.transformer = transformer;
//     }
// 
//     public Object transform(Object value, Class<?> type) {
//         if (transformer.accepts(value, type)) {
//             value = transformer.transform(value, type);
//         } 
//         
//         if (next != null) {
//             value = next.transform(value, type);
//         }
// 
//         return value;
//     }
// 
//     public void add(Transformer transformer) {
//         if (this.next == null) {
//             this.next = new TransformerChain(transformer);
//         } else {
//             this.next.add(transformer);
//         }
//     }
// }


// Path: src/test/java/br/com/six2six/fixturefactory/transformer/TransformerChainTest.java
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import br.com.six2six.fixturefactory.transformer.Transformer;
import br.com.six2six.fixturefactory.transformer.TransformerChain;

package br.com.six2six.fixturefactory.transformer;




public class TransformerChainTest {

    @Test
    public void shouldUseFirstTransformer() {
        TransformerChain transformerChain = new TransformerChain(new FirstTransformer());
        assertEquals("A1", transformerChain.transform("A", String.class));
    }
    
    @Test
    public void shouldUseSecondTransformer() {
        TransformerChain transformerChain = new TransformerChain(new FirstTransformer());
        transformerChain.add(new SecondTransformer());
        assertEquals("B2", transformerChain.transform("B", String.class));        
    }
    
    @Test
    public void shouldUseBothTransformersInOrderOfInclusion() {
        TransformerChain transformerChain = new TransformerChain(new FirstTransformer());
        transformerChain.add(new SecondTransformer());
        assertEquals("AB12", transformerChain.transform("AB", String.class));        
    }
    
    @Test
    public void shouldNotUseAnyOfTheTransformers() {
        TransformerChain transformerChain = new TransformerChain(new FirstTransformer());
        transformerChain.add(new SecondTransformer());
        assertEquals("C", transformerChain.transform("C", String.class));        
    }
}

class FirstTransformer implements Transformer {