/**
 * Copyright (c) 2016 Chiral Behaviors, LLC, all rights reserved.
 * 
 
 *  This file is part of Ultrastructure.
 *
 *  Ultrastructure is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  ULtrastructure is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with Ultrastructure.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.chiralbehaviors.CoRE.loader;

import org.junit.Test;

import com.chiralbehaviors.CoRE.utils.DbaConfiguration;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

/**
 * @author hhildebrand
 *
 */
public class LoaderTest {

    @Test
    public void testLoader() throws Exception {
        ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
        DbaConfiguration config = mapper.readValue(getClass().getResourceAsStream("/loader.yml"),
                                                   DbaConfiguration.class);
        config.dropDatabase = true;
        Loader loader = new Loader(config);
        try {
            loader.execute();
        } finally {
            loader.dropDatabase();
        }
    }
}

@@ -843,16 +843,45 @@
 oader;%0A%0A
+import java.sql.Connection;%0A%0A
 import o
@@ -1423,16 +1423,318 @@
 class);%0A
+        try (Connection dbaConnection = config.getDbaConnection()) %7B%0A            dbaConnection.prepareStatement(%22DROP DATABASE IF EXISTS testme%22)%0A                         .execute();%0A            dbaConnection.prepareStatement(%22DROP ROLE IF EXISTS scott%22)%0A                         .execute();%0A        %7D%0A
         

drop db before test