// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/domain/Customer.java
// public class Customer extends CustomerAbstract
// {
//     public Customer()
//     {
//         super();
//         // You must not modify this constructor. Mithra calls this internally.
//         // You can call this constructor. You can also add new constructors.
//     }
// 
//     public Customer(int customerId, String firstName, String lastName)
//     {
//         super();
//         this.setCustomerId(customerId);
//         this.setFirstName(firstName);
//         this.setLastName(lastName);
//     }
// }
// 
// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/domain/CustomerAccount.java
// public class CustomerAccount extends CustomerAccountAbstract
// {
//     public CustomerAccount()
//     {
//         super();
//         // You must not modify this constructor. Mithra calls this internally.
//         // You can call this constructor. You can also add new constructors.
//     }
// }
// 
// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/domain/CustomerAccountList.java
// public class CustomerAccountList extends CustomerAccountListAbstract
// {
//     public CustomerAccountList()
//     {
//         super();
//     }
// 
//     public CustomerAccountList(int initialSize)
//     {
//         super(initialSize);
//     }
// 
//     public CustomerAccountList(Collection c)
//     {
//         super(c);
//     }
// 
//     public CustomerAccountList(Operation operation)
//     {
//         super(operation);
//     }
// }
// 
// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/serialization/SimpleBankJacksonObjectMapperProvider.java
// public class SimpleBankJacksonObjectMapperProvider implements ContextResolver<ObjectMapper>
// {
//     final ObjectMapper defaultObjectMapper;
// 
//     public SimpleBankJacksonObjectMapperProvider()
//     {
//         defaultObjectMapper = new ObjectMapper();
//         defaultObjectMapper.registerModule(new JacksonReladomoModule());
//     }
// 
//     @Override
//     public ObjectMapper getContext(Class<?> type)
//     {
//         return defaultObjectMapper;
//     }
// }
// 
// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/web/SimpleBankServer.java
// public class SimpleBankServer
// {
//     private ResourceConfig config;
// 
//     public SimpleBankServer(String runtimeConfigXML) throws Exception
//     {
//         this.initReladomo(runtimeConfigXML);
//     }
// 
//     protected void initReladomo(String runtimeConfigXML) throws Exception
//     {
//         MithraManager mithraManager = MithraManagerProvider.getMithraManager();
//         mithraManager.setTransactionTimeout(60 * 1000);
//         InputStream stream = loadReladomoXMLFromClasspath(runtimeConfigXML);
//         MithraManagerProvider.getMithraManager().readConfiguration(stream);
//         stream.close();
//     }
// 
//     private InputStream loadReladomoXMLFromClasspath(String fileName) throws Exception
//     {
//         InputStream stream = SimpleBankServer.class.getClassLoader().getResourceAsStream(fileName);
//         if (stream == null)
//         {
//             throw new Exception("Failed to locate " + fileName + " in classpath");
//         }
//         return stream;
//     }
// 
//     protected void initResources()
//     {
//         this.config = new ResourceConfig(CustomerResource.class);
//         config.register(JacksonFeature.class);
//         config.register(SimpleBankJacksonObjectMapperProvider.class);
//     }
// 
//     public void start() throws IOException
//     {
//         initResources();
//         URI baseUri = UriBuilder.fromUri("http://localhost/").port(9998).build();
//         HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config);
//         server.start();
//     }
// 
//     public static void main(String[] args) throws Exception
//     {
//         String runtimeConfigXML = "reladomoxml/SimpleBankRuntimeConfiguration.xml";
//         new SimpleBankServer(runtimeConfigXML).start();
//     }
// }


import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import static org.junit.Assert.assertEquals;
import com.gs.fw.common.mithra.test.ConnectionManagerForTests;
import com.gs.fw.common.mithra.test.MithraTestResource;
import com.gs.fw.common.mithra.util.serializer.Serialized;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.junit.Before;
import org.junit.Test;
import simplebank.domain.Customer;
import simplebank.domain.CustomerAccount;
import simplebank.domain.CustomerAccountList;
import simplebank.serialization.SimpleBankJacksonObjectMapperProvider;
import simplebank.web.SimpleBankServer;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
/*
Copyright 2016 Goldman Sachs.
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 simplebank.api;




/**
 * Created by stanle on 2/18/17.
 */
public class SimpleBankAPITest
{
    private String testRuntimeConfigXML = "testconfig/SimpleBankTestRuntimeConfiguration.xml";

    @Before
    public void setup() throws Exception
    {
        intializeReladomoForTest();
        initializeApp();
    }

    private void intializeReladomoForTest()
    {
        MithraTestResource testResource = new MithraTestResource(testRuntimeConfigXML);
        ConnectionManagerForTests connectionManager = ConnectionManagerForTests.getInstance("test_db");
        testResource.createSingleDatabase(connectionManager, "testconfig/SimpleBankTestData.txt");
        testResource.setUp();
    }

    private void initializeApp() throws Exception
    {
// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/domain/Customer.java
// public class Customer extends CustomerAbstract
// {
//     public Customer()
//     {
//         super();
//         // You must not modify this constructor. Mithra calls this internally.
//         // You can call this constructor. You can also add new constructors.
//     }
// 
//     public Customer(int customerId, String firstName, String lastName)
//     {
//         super();
//         this.setCustomerId(customerId);
//         this.setFirstName(firstName);
//         this.setLastName(lastName);
//     }
// }
// 
// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/domain/CustomerAccount.java
// public class CustomerAccount extends CustomerAccountAbstract
// {
//     public CustomerAccount()
//     {
//         super();
//         // You must not modify this constructor. Mithra calls this internally.
//         // You can call this constructor. You can also add new constructors.
//     }
// }
// 
// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/domain/CustomerAccountList.java
// public class CustomerAccountList extends CustomerAccountListAbstract
// {
//     public CustomerAccountList()
//     {
//         super();
//     }
// 
//     public CustomerAccountList(int initialSize)
//     {
//         super(initialSize);
//     }
// 
//     public CustomerAccountList(Collection c)
//     {
//         super(c);
//     }
// 
//     public CustomerAccountList(Operation operation)
//     {
//         super(operation);
//     }
// }
// 
// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/serialization/SimpleBankJacksonObjectMapperProvider.java
// public class SimpleBankJacksonObjectMapperProvider implements ContextResolver<ObjectMapper>
// {
//     final ObjectMapper defaultObjectMapper;
// 
//     public SimpleBankJacksonObjectMapperProvider()
//     {
//         defaultObjectMapper = new ObjectMapper();
//         defaultObjectMapper.registerModule(new JacksonReladomoModule());
//     }
// 
//     @Override
//     public ObjectMapper getContext(Class<?> type)
//     {
//         return defaultObjectMapper;
//     }
// }
// 
// Path: reladomo-tour/tour-examples/simple-bank/src/main/java/simplebank/web/SimpleBankServer.java
// public class SimpleBankServer
// {
//     private ResourceConfig config;
// 
//     public SimpleBankServer(String runtimeConfigXML) throws Exception
//     {
//         this.initReladomo(runtimeConfigXML);
//     }
// 
//     protected void initReladomo(String runtimeConfigXML) throws Exception
//     {
//         MithraManager mithraManager = MithraManagerProvider.getMithraManager();
//         mithraManager.setTransactionTimeout(60 * 1000);
//         InputStream stream = loadReladomoXMLFromClasspath(runtimeConfigXML);
//         MithraManagerProvider.getMithraManager().readConfiguration(stream);
//         stream.close();
//     }
// 
//     private InputStream loadReladomoXMLFromClasspath(String fileName) throws Exception
//     {
//         InputStream stream = SimpleBankServer.class.getClassLoader().getResourceAsStream(fileName);
//         if (stream == null)
//         {
//             throw new Exception("Failed to locate " + fileName + " in classpath");
//         }
//         return stream;
//     }
// 
//     protected void initResources()
//     {
//         this.config = new ResourceConfig(CustomerResource.class);
//         config.register(JacksonFeature.class);
//         config.register(SimpleBankJacksonObjectMapperProvider.class);
//     }
// 
//     public void start() throws IOException
//     {
//         initResources();
//         URI baseUri = UriBuilder.fromUri("http://localhost/").port(9998).build();
//         HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config);
//         server.start();
//     }
// 
//     public static void main(String[] args) throws Exception
//     {
//         String runtimeConfigXML = "reladomoxml/SimpleBankRuntimeConfiguration.xml";
//         new SimpleBankServer(runtimeConfigXML).start();
//     }
// }


// Path: reladomo-tour/tour-examples/simple-bank/src/test/java/simplebank/api/SimpleBankAPITest.java
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import static org.junit.Assert.assertEquals;
import com.gs.fw.common.mithra.test.ConnectionManagerForTests;
import com.gs.fw.common.mithra.test.MithraTestResource;
import com.gs.fw.common.mithra.util.serializer.Serialized;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.junit.Before;
import org.junit.Test;
import simplebank.domain.Customer;
import simplebank.domain.CustomerAccount;
import simplebank.domain.CustomerAccountList;
import simplebank.serialization.SimpleBankJacksonObjectMapperProvider;
import simplebank.web.SimpleBankServer;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

/*
Copyright 2016 Goldman Sachs.
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 simplebank.api;




/**
 * Created by stanle on 2/18/17.
 */
public class SimpleBankAPITest
{
    private String testRuntimeConfigXML = "testconfig/SimpleBankTestRuntimeConfiguration.xml";

    @Before
    public void setup() throws Exception
    {
        intializeReladomoForTest();
        initializeApp();
    }

    private void intializeReladomoForTest()
    {
        MithraTestResource testResource = new MithraTestResource(testRuntimeConfigXML);
        ConnectionManagerForTests connectionManager = ConnectionManagerForTests.getInstance("test_db");
        testResource.createSingleDatabase(connectionManager, "testconfig/SimpleBankTestData.txt");
        testResource.setUp();
    }

    private void initializeApp() throws Exception
    {
        new SimpleBankServer(testRuntimeConfigXML).start();