<commit_before>/*
 * 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 org.jdbi.v3.freemarker;

import static org.assertj.core.api.Assertions.assertThat;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;

import org.jdbi.v3.core.rule.H2DatabaseRule;
import org.jdbi.v3.core.Handle;
import org.jdbi.v3.core.Something;
import org.jdbi.v3.core.statement.StatementContext;
import org.jdbi.v3.core.mapper.RowMapper;
import org.jdbi.v3.sqlobject.customizer.Bind;
import org.jdbi.v3.sqlobject.customizer.BindBean;
import org.jdbi.v3.sqlobject.statement.SqlBatch;
import org.jdbi.v3.sqlobject.SqlObjectPlugin;
import org.jdbi.v3.sqlobject.statement.SqlQuery;
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
import org.jdbi.v3.sqlobject.customizer.Define;
import org.jdbi.v3.sqlobject.config.RegisterRowMapper;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

public class FreemarkerSqlLocatorTest {
    @Rule
    public H2DatabaseRule dbRule = new H2DatabaseRule().withPlugin(new SqlObjectPlugin());

    private Handle handle;

    @Before
    public void setUp() throws Exception {
        handle = dbRule.getSharedHandle();
    }

    @Test
    public void testBaz() throws Exception {
        Wombat wombat = handle.attach(Wombat.class);
        wombat.insert(new Something(7, "Henning"));

        String name = handle.createQuery("select name from something where id = 7")
                            .mapTo(String.class)
                            .findOnly();

        assertThat(name).isEqualTo("Henning");
    }

    @Test
    public void testBam() throws Exception {
        handle.execute("insert into something (id, name) values (6, 'Martin')");

        Something s = handle.attach(Wombat.class).findById(6L);
        assertThat(s.getName()).isEqualTo("Martin");
    }

    @Test
    public void testDefinedList() throws Exception {
        handle.execute("insert into something (id, name) values (6, 'Martin')");
        handle.execute("insert into something (id, name) values (7, 'Peter')");

        List<String> s = handle.attach(Wombat.class).findNamesForIds(Arrays.asList(6,7));
        assertThat(s.size()).isEqualTo(2);
        assertThat(s.get(0)).isEqualTo("Martin");
        assertThat(s.get(1)).isEqualTo("Peter");
    }

    @Test
    public void testDefinedBeanList() throws Exception {
        handle.execute("insert into something (id, name) values (6, 'Martin')");
        handle.execute("insert into something (id, name) values (7, 'Peter')");

        List<String> s = handle.attach(Wombat.class).findNamesForSomethings(Arrays.asList(new Something(6, "Martin"), new Something(7, "Peter")));
        assertThat(s.size()).isEqualTo(2);
        assertThat(s.get(0)).isEqualTo("Martin");
        assertThat(s.get(1)).isEqualTo("Peter");
    }

    @Test
    public void testBap() throws Exception {
        handle.execute("insert into something (id, name) values (2, 'Bean')");
        Wombat w = handle.attach(Wombat.class);
        assertThat(w.findNameFor(2)).isEqualTo("Bean");
    }

    @Test
    public void testDefines() throws Exception {
        handle.attach(Wombat.class).weirdInsert("something", "id", "name", 5, "Bouncer");
        handle.attach(Wombat.class).weirdInsert("something", "id", "name", 6, "Bean");
        String name = handle.createQuery("select name from something where id = 5")
                            .mapTo(String.class)
                            .findOnly();

        assertThat(name).isEqualTo("Bouncer");
    }

    @Test
    public void testBatching() throws Exception {
        Wombat roo = handle.attach(Wombat.class);
        roo.insertBunches(new Something(1, "Jeff"), new Something(2, "Brian"));

        assertThat(roo.findById(1L)).isEqualTo(new Something(1, "Jeff"));
        assertThat(roo.findById(2L)).isEqualTo(new Something(2, "Brian"));
    }<commit_msg>assert cosmetics<commit_after>/*
 * 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 org.jdbi.v3.freemarker;

import static org.assertj.core.api.Assertions.assertThat;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;

import org.jdbi.v3.core.rule.H2DatabaseRule;
import org.jdbi.v3.core.Handle;
import org.jdbi.v3.core.Something;
import org.jdbi.v3.core.statement.StatementContext;
import org.jdbi.v3.core.mapper.RowMapper;
import org.jdbi.v3.sqlobject.customizer.Bind;
import org.jdbi.v3.sqlobject.customizer.BindBean;
import org.jdbi.v3.sqlobject.statement.SqlBatch;
import org.jdbi.v3.sqlobject.SqlObjectPlugin;
import org.jdbi.v3.sqlobject.statement.SqlQuery;
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
import org.jdbi.v3.sqlobject.customizer.Define;
import org.jdbi.v3.sqlobject.config.RegisterRowMapper;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

public class FreemarkerSqlLocatorTest {
    @Rule
    public H2DatabaseRule dbRule = new H2DatabaseRule().withPlugin(new SqlObjectPlugin());

    private Handle handle;

    @Before
    public void setUp() throws Exception {
        handle = dbRule.getSharedHandle();
    }

    @Test
    public void testBaz() throws Exception {
        Wombat wombat = handle.attach(Wombat.class);
        wombat.insert(new Something(7, "Henning"));

        String name = handle.createQuery("select name from something where id = 7")
                            .mapTo(String.class)
                            .findOnly();

        assertThat(name).isEqualTo("Henning");
    }

    @Test
    public void testBam() throws Exception {
        handle.execute("insert into something (id, name) values (6, 'Martin')");

        Something s = handle.attach(Wombat.class).findById(6L);
        assertThat(s.getName()).isEqualTo("Martin");
    }

    @Test
    public void testDefinedList() throws Exception {
        handle.execute("insert into something (id, name) values (6, 'Martin')");
        handle.execute("insert into something (id, name) values (7, 'Peter')");

        List<String> s = handle.attach(Wombat.class).findNamesForIds(Arrays.asList(6,7));
        assertThat(s.size()).isEqualTo(2);
        assertThat(s).containsExactly("Martin", "Peter");
    }

    @Test
    public void testDefinedBeanList() throws Exception {
        handle.execute("insert into something (id, name) values (6, 'Martin')");
        handle.execute("insert into something (id, name) values (7, 'Peter')");

        List<String> s = handle.attach(Wombat.class).findNamesForSomethings(Arrays.asList(new Something(6, "Martin"), new Something(7, "Peter")));
        assertThat(s.size()).isEqualTo(2);
        assertThat(s).containsExactly("Martin", "Peter");
    }

    @Test
    public void testBap() throws Exception {
        handle.execute("insert into something (id, name) values (2, 'Bean')");
        Wombat w = handle.attach(Wombat.class);
        assertThat(w.findNameFor(2)).isEqualTo("Bean");
    }

    @Test
    public void testDefines() throws Exception {
        handle.attach(Wombat.class).weirdInsert("something", "id", "name", 5, "Bouncer");
        handle.attach(Wombat.class).weirdInsert("something", "id", "name", 6, "Bean");
        String name = handle.createQuery("select name from something where id = 5")
                            .mapTo(String.class)
                            .findOnly();

        assertThat(name).isEqualTo("Bouncer");
    }

    @Test
    public void testBatching() throws Exception {
        Wombat roo = handle.attach(Wombat.class);
        roo.insertBunches(new Something(1, "Jeff"), new Something(2, "Brian"));

        assertThat(roo.findById(1L)).isEqualTo(new Something(1, "Jeff"));
        assertThat(roo.findById(2L)).isEqualTo(new Something(2, "Brian"));
    }
{'fraction_non_alphanumeric': 0.12931919261033184, 'fraction_numerical': 0.01094765651727677, 'mean_word_length': 3.3588469184890655, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '261518', 'n_tokens_mistral': 2698, 'n_tokens_neox': 2643, 'n_words': 631}