<commit_before>package com.grahamedgecombe.db;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.concurrent.ExecutionException;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.hsqldb.jdbc.JDBCDataSource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public final class DatabaseServiceTest {
	private @Nullable DatabaseService service;

	@Before
	public void setUp() {
		JDBCDataSource ds = new JDBCDataSource();
		ds.setURL("jdbc:hsqldb:mem:test");

		service = DatabaseService.builder(ds).setBackoffStrategy(attempt -> 0).build();
		service.startAsync().awaitRunning();
	}

	@After
	public void tearDown() {
		if (service != null) {
			service.stopAsync().awaitTerminated();
		}
	}

	@Test
	public void testSuccess() throws ExecutionException, InterruptedException {
		if (service == null) {
			throw new IllegalStateException();
		}

		int result = service.execute(connection -> {
			try (PreparedStatement stmt = connection.prepareStatement("VALUES (42);")) {
				try (ResultSet rs = stmt.executeQuery()) {
					if (!rs.next()) {
						throw new IllegalStateException();
					}

					return rs.getInt(1);
				}
			}
		});

		assertEquals(42, result);
	}

	@Test(expected = ExecutionException.class)
	public void testFailure() throws ExecutionException, InterruptedException {
		if (service == null) {
			throw new IllegalStateException();
		}

		service.<@Nullable Void>execute(connection -> {
			try (PreparedStatement stmt = connection.prepareStatement("INVALID SYNTAX")) {
				stmt.executeQuery();
				return null;
			}
		});
	}
}<commit_msg>Remove redundant throws from test methods.<commit_after>package com.grahamedgecombe.db;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.concurrent.ExecutionException;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.hsqldb.jdbc.JDBCDataSource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public final class DatabaseServiceTest {
	private @Nullable DatabaseService service;

	@Before
	public void setUp() {
		JDBCDataSource ds = new JDBCDataSource();
		ds.setURL("jdbc:hsqldb:mem:test");

		service = DatabaseService.builder(ds).setBackoffStrategy(attempt -> 0).build();
		service.startAsync().awaitRunning();
	}

	@After
	public void tearDown() {
		if (service != null) {
			service.stopAsync().awaitTerminated();
		}
	}

	@Test
	public void testSuccess() throws ExecutionException {
		if (service == null) {
			throw new IllegalStateException();
		}

		int result = service.execute(connection -> {
			try (PreparedStatement stmt = connection.prepareStatement("VALUES (42);")) {
				try (ResultSet rs = stmt.executeQuery()) {
					if (!rs.next()) {
						throw new IllegalStateException();
					}

					return rs.getInt(1);
				}
			}
		});

		assertEquals(42, result);
	}

	@Test(expected = ExecutionException.class)
	public void testFailure() throws ExecutionException {
		if (service == null) {
			throw new IllegalStateException();
		}

		service.<@Nullable Void>execute(connection -> {
			try (PreparedStatement stmt = connection.prepareStatement("INVALID SYNTAX")) {
				stmt.executeQuery();
				return null;
			}
		});
	}
}
{'fraction_non_alphanumeric': 0.12443778110944528, 'fraction_numerical': 0.003598200899550225, 'mean_word_length': 4.371980676328502, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4377650', 'n_tokens_mistral': 1152, 'n_tokens_neox': 996, 'n_words': 219}