Skip to content

Instantly share code, notes, and snippets.

@pedrovitorlima
Created May 2, 2019 02:39
Show Gist options
  • Save pedrovitorlima/d6e0c8ea3db5aebe26162004b2befad1 to your computer and use it in GitHub Desktop.
Save pedrovitorlima/d6e0c8ea3db5aebe26162004b2befad1 to your computer and use it in GitHub Desktop.
package br.pedro.springboot.springvault.domain;
import javax.persistence.*;
import java.math.BigInteger;
@Entity
@Table(name="foo", schema = "public")
public class Foo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private BigInteger id;
public BigInteger getId() { return this.id; }
public void setId(BigInteger id) {this.id = id;}
}
package br.pedro.springboot.springvault.repository;
import br.pedro.springboot.springvault.domain.Foo;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.math.BigInteger;
@Repository
public interface FooRepository extends CrudRepository<Foo, BigInteger> {
}
package br.pedro.springboot.springvault.repository;
import br.pedro.springboot.springvault.domain.Foo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest
public class FooRepositoryTest {
@Autowired
private FooRepository fooRepository;
@Test
public void testFindAllShouldReturnSomething() {
Foo foo = new Foo();
fooRepository.save(foo);
Iterable<Foo> allElements = fooRepository.findAll();
assertTrue(allElements.iterator().hasNext());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment