Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Favor Java over Kotlin #244

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.example.data.jdbc.h2.kotlin;

import com.example.data.jdbc.h2.kotlin.model.Author;
import com.example.data.jdbc.h2.kotlin.model.Book;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.jdbc.DataJdbcTest;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.Set;

@DataJdbcTest
class DataJdbcTests {

@Autowired
private JdbcTemplate jdbcTemplate;

@Autowired
private AuthorRepository authorRepository;

@Test
void shouldHaveSchema() {
Assertions.assertThatNoException().isThrownBy(() -> jdbcTemplate.execute("SELECT * FROM author"));
}

@Test
void shouldSaveAndLoad() {

var book1 = new Book(null, "book-1");
var author1 = new Author(null, "author-1", Set.of(book1));
authorRepository.save(author1);
var found = authorRepository.queryFindByName("author-1");
Assertions.assertThat(found).isNotNull();
Assertions.assertThat(found.getId()).isNotNull();
Assertions.assertThat(found.getName()).isEqualTo("author-1");
Assertions.assertThat(found.getBooks()).hasSize(1);
}

}

This file was deleted.