Created
May 2, 2019 02:39
-
-
Save pedrovitorlima/d6e0c8ea3db5aebe26162004b2befad1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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