// Path: reladomo-tour/tour-examples/auditonly-bank/src/main/java/auditonlybank/domain/Customer.java
// public class Customer extends CustomerAbstract
// {
//     public Customer(Timestamp processingDate)
//     {
//         super(processingDate);
//         // You must not modify this constructor. Mithra calls this internally.
//         // You can call this constructor. You can also add new constructors.
//     }
// 
//     public Customer()
//     {
//         this(TimestampProvider.getInfinityDate());
//     }
// }
// 
// Path: reladomo-tour/tour-examples/auditonly-bank/src/main/java/auditonlybank/domain/CustomerAccount.java
// public class CustomerAccount extends CustomerAccountAbstract
// {
//     public CustomerAccount(Timestamp processingDate)
//     {
//         super(processingDate);
//         // You must not modify this constructor. Mithra calls this internally.
//         // You can call this constructor. You can also add new constructors.
//     }
// 
//     public CustomerAccount()
//     {
//         this(TimestampProvider.getInfinityDate());
//     }
// }
// 
// Path: reladomo-tour/tour-examples/auditonly-bank/src/main/java/auditonlybank/util/DateUtils.java
// public class DateUtils
// {
//     private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("YYY-MM-dd");
// 
//     private static final DateTimeFormatter DATE_TIME_FORMATTER_FULL = DateTimeFormat.forPattern("YYY-MM-dd HH:mm:ss.SSS");
// 
//     public static Timestamp parseFull(String dateTimeString)
//     {
//         DateTime dateTime = DATE_TIME_FORMATTER_FULL.parseDateTime(dateTimeString);
//         return new Timestamp(dateTime.toDateTime().getMillis());
//     }
// 
//     public static String printFull(Timestamp ts)
//     {
//         return DATE_TIME_FORMATTER_FULL.print(ts.getTime());
//     }
// 
//     public static Timestamp parse(String dateTimeString)
//     {
//         DateTime dateTime = DATE_TIME_FORMATTER.parseDateTime(dateTimeString);
//         return new Timestamp(dateTime.toDateTime().getMillis());
//     }
// 
//     public static String print(Timestamp ts)
//     {
//         return DATE_TIME_FORMATTER.print(ts.getTime());
//     }
// }


import java.nio.file.Path;
import java.sql.Timestamp;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import auditonlybank.domain.Customer;
import auditonlybank.domain.CustomerAccount;
import auditonlybank.domain.CustomerAccountFinder;
import auditonlybank.util.DateUtils;
import com.gs.fw.common.mithra.MithraManagerProvider;
import com.gs.fw.common.mithra.MithraTransaction;
import com.gs.fw.common.mithra.finder.Operation;
import com.gs.fw.common.mithra.test.ConnectionManagerForTests;
import com.gs.fw.common.mithra.test.MithraTestResource;
import com.gs.fw.common.mithra.util.dbextractor.DbExtractor;
import org.junit.Before;
import org.junit.Test;
import java.nio.file.Files;
        {
            // We set the processing time to simulate the update opening on a specific date - Do not do this in production
            doNotDoThisInProduction(date, tx);

            Operation id = CustomerAccountFinder.accountId().eq(accountId);
            CustomerAccount account = CustomerAccountFinder.findOne(id);
            account.setBalance(account.getBalance() + deposit);
            return null;
        });
    }

    /*
        This test relies on an account that has been loaded
        into memory via the test data file. See the test setup for details.
     */
    @Test
    public void run2() throws Exception
    {
        int accountId = 5678;
        balanceAsOfJan1(accountId);
        balanceAsOfJan20(accountId);
        balanceAsOfJan25(accountId);
        balanceAsOfJan17(accountId);
    }

    private void balanceAsOfJan1(int accountId)
    {
        Timestamp date = DateUtils.parse("2017-01-01");
        Operation idOp = CustomerAccountFinder.accountId().eq(accountId);
        Operation dateOp = CustomerAccountFinder.processingDate().eq(date);
// Path: reladomo-tour/tour-examples/auditonly-bank/src/main/java/auditonlybank/domain/Customer.java
// public class Customer extends CustomerAbstract
// {
//     public Customer(Timestamp processingDate)
//     {
//         super(processingDate);
//         // You must not modify this constructor. Mithra calls this internally.
//         // You can call this constructor. You can also add new constructors.
//     }
// 
//     public Customer()
//     {
//         this(TimestampProvider.getInfinityDate());
//     }
// }
// 
// Path: reladomo-tour/tour-examples/auditonly-bank/src/main/java/auditonlybank/domain/CustomerAccount.java
// public class CustomerAccount extends CustomerAccountAbstract
// {
//     public CustomerAccount(Timestamp processingDate)
//     {
//         super(processingDate);
//         // You must not modify this constructor. Mithra calls this internally.
//         // You can call this constructor. You can also add new constructors.
//     }
// 
//     public CustomerAccount()
//     {
//         this(TimestampProvider.getInfinityDate());
//     }
// }
// 
// Path: reladomo-tour/tour-examples/auditonly-bank/src/main/java/auditonlybank/util/DateUtils.java
// public class DateUtils
// {
//     private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("YYY-MM-dd");
// 
//     private static final DateTimeFormatter DATE_TIME_FORMATTER_FULL = DateTimeFormat.forPattern("YYY-MM-dd HH:mm:ss.SSS");
// 
//     public static Timestamp parseFull(String dateTimeString)
//     {
//         DateTime dateTime = DATE_TIME_FORMATTER_FULL.parseDateTime(dateTimeString);
//         return new Timestamp(dateTime.toDateTime().getMillis());
//     }
// 
//     public static String printFull(Timestamp ts)
//     {
//         return DATE_TIME_FORMATTER_FULL.print(ts.getTime());
//     }
// 
//     public static Timestamp parse(String dateTimeString)
//     {
//         DateTime dateTime = DATE_TIME_FORMATTER.parseDateTime(dateTimeString);
//         return new Timestamp(dateTime.toDateTime().getMillis());
//     }
// 
//     public static String print(Timestamp ts)
//     {
//         return DATE_TIME_FORMATTER.print(ts.getTime());
//     }
// }


// Path: reladomo-tour/tour-examples/auditonly-bank/src/test/java/auditonlybank/api/AuditOnlyChainingInAction.java
import java.nio.file.Path;
import java.sql.Timestamp;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import auditonlybank.domain.Customer;
import auditonlybank.domain.CustomerAccount;
import auditonlybank.domain.CustomerAccountFinder;
import auditonlybank.util.DateUtils;
import com.gs.fw.common.mithra.MithraManagerProvider;
import com.gs.fw.common.mithra.MithraTransaction;
import com.gs.fw.common.mithra.finder.Operation;
import com.gs.fw.common.mithra.test.ConnectionManagerForTests;
import com.gs.fw.common.mithra.test.MithraTestResource;
import com.gs.fw.common.mithra.util.dbextractor.DbExtractor;
import org.junit.Before;
import org.junit.Test;
import java.nio.file.Files;

        {
            // We set the processing time to simulate the update opening on a specific date - Do not do this in production
            doNotDoThisInProduction(date, tx);

            Operation id = CustomerAccountFinder.accountId().eq(accountId);
            CustomerAccount account = CustomerAccountFinder.findOne(id);
            account.setBalance(account.getBalance() + deposit);
            return null;
        });
    }

    /*
        This test relies on an account that has been loaded
        into memory via the test data file. See the test setup for details.
     */
    @Test
    public void run2() throws Exception
    {
        int accountId = 5678;
        balanceAsOfJan1(accountId);
        balanceAsOfJan20(accountId);
        balanceAsOfJan25(accountId);
        balanceAsOfJan17(accountId);
    }

    private void balanceAsOfJan1(int accountId)
    {
        Timestamp date = DateUtils.parse("2017-01-01");
        Operation idOp = CustomerAccountFinder.accountId().eq(accountId);
        Operation dateOp = CustomerAccountFinder.processingDate().eq(date);
        CustomerAccount account = CustomerAccountFinder.findOne(idOp.and(dateOp));