// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
// 
//     WRITE,
//     READ_FAST,
//     READ_COMMITTED;
// }
// 
// Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/SampleController.java
// @Persistent
// public class SampleController {
// 
//     @PersistentObject
//     protected SampleObject object;
// 
//     public void writeMethod() {
//         assertNotNull(object);
//         object.setField1("changed field1");
//         object.value += 14;
//     }
// 
//     public void writeMethod2(int val1, String val2) {
//         assertNotNull(object);
//         object.setField1(val2);
//         object.value += val1;
//     }
// 
//     @GET
//     public String readMethod() {
//         assertNotNull(object);
//         object.value += 7;
//         return object.getField1();
//     }
// 
//     @GET
//     public String readMethod(String postfix) {
//         assertNotNull(object);
//         object.value += 7;
//         return object.getField1() + postfix;
//     }
// 
//     public SampleObject getObject() {
//         return this.object;
//     }
// 
// }


import java.lang.reflect.Method;
import javax.inject.Inject;
import org.jglue.cdiunit.CdiRunner;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.SampleController;
import pl.setblack.badass.Politician;

/*
 *  Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
 *  http://www.apache.org/licenses/LICENSE-2.0
 */
package pl.setblack.airomem.direct.impl;


/**
 *
 * @author jarek ratajski
 */
@RunWith(CdiRunner.class)
public class TransactionAnalyzerTest {

    private final SampleController controler = new SampleController();

    @Inject
    private TransactionAnalyzer analyzer;

    public TransactionAnalyzerTest() {
    }

    private Method getMethod(final Object object, final String name) {
        return Politician.beatAroundTheBush(() -> object.getClass().getMethod(name));

    }

    @Before
    public void setUp() {
    }

    @Test
    public void shouldSayWriteForWriteMethod() {
        final Method method = getMethod(controler, "writeMethod");
        //THEN

// Path: airomem-direct/src/main/java/pl/setblack/airomem/direct/OperationType.java
// public enum OperationType {
// 
//     WRITE,
//     READ_FAST,
//     READ_COMMITTED;
// }
// 
// Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/SampleController.java
// @Persistent
// public class SampleController {
// 
//     @PersistentObject
//     protected SampleObject object;
// 
//     public void writeMethod() {
//         assertNotNull(object);
//         object.setField1("changed field1");
//         object.value += 14;
//     }
// 
//     public void writeMethod2(int val1, String val2) {
//         assertNotNull(object);
//         object.setField1(val2);
//         object.value += val1;
//     }
// 
//     @GET
//     public String readMethod() {
//         assertNotNull(object);
//         object.value += 7;
//         return object.getField1();
//     }
// 
//     @GET
//     public String readMethod(String postfix) {
//         assertNotNull(object);
//         object.value += 7;
//         return object.getField1() + postfix;
//     }
// 
//     public SampleObject getObject() {
//         return this.object;
//     }
// 
// }


// Path: airomem-direct/src/test/java/pl/setblack/airomem/direct/impl/TransactionAnalyzerTest.java
import java.lang.reflect.Method;
import javax.inject.Inject;
import org.jglue.cdiunit.CdiRunner;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import pl.setblack.airomem.direct.OperationType;
import pl.setblack.airomem.direct.SampleController;
import pl.setblack.badass.Politician;

/*
 *  Copyright (c) Jarek Ratajski, Licensed under the Apache License, Version 2.0
 *  http://www.apache.org/licenses/LICENSE-2.0
 */
package pl.setblack.airomem.direct.impl;


/**
 *
 * @author jarek ratajski
 */
@RunWith(CdiRunner.class)
public class TransactionAnalyzerTest {

    private final SampleController controler = new SampleController();

    @Inject
    private TransactionAnalyzer analyzer;

    public TransactionAnalyzerTest() {
    }

    private Method getMethod(final Object object, final String name) {
        return Politician.beatAroundTheBush(() -> object.getClass().getMethod(name));

    }

    @Before
    public void setUp() {
    }

    @Test
    public void shouldSayWriteForWriteMethod() {
        final Method method = getMethod(controler, "writeMethod");
        //THEN

        assertEquals(OperationType.WRITE, analyzer.sayTypeOf(method));
