Merge branch 'master' of https://github.com/juliuskrah/tutorials into juliuskrah-master

This commit is contained in:
Zeger Hendrikse 2016-07-08 01:06:13 +02:00
commit 8066195a85
5 changed files with 45 additions and 45 deletions

View File

@ -6,8 +6,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
System.setProperty("spring.config.name", "demo");
SpringApplication.run(DemoApplication.class, args);
}
public static void main(String[] args) {
System.setProperty("spring.config.name", "demo");
SpringApplication.run(DemoApplication.class, args);
}
}

View File

@ -8,33 +8,32 @@ import javax.persistence.Id;
@Entity
public class Foo implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Integer id;
private String name;
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Integer id;
private String name;
public Foo() {
}
public Foo() {
}
public Foo(String name) {
this.name = name;
}
public Foo(String name) {
this.name = name;
}
public Integer getId() {
return id;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -4,5 +4,5 @@ import org.baeldung.boot.model.Foo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface FooRepository extends JpaRepository<Foo, Integer> {
public Foo findByName(String name);
public Foo findByName(String name);
}

View File

@ -11,8 +11,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
@WebAppConfiguration
public class DemoApplicationTests {
@Test
public void contextLoads() {
}
@Test
public void contextLoads() {
}
}

View File

@ -15,19 +15,20 @@ import org.springframework.transaction.annotation.Transactional;
@Transactional
public class FooRepositoryTest extends DemoApplicationTests {
@Autowired
private FooRepository fooRepository;
@Autowired
private FooRepository fooRepository;
@Before
public void setUp() {
fooRepository.save(new Foo("Foo"));
fooRepository.save(new Foo("Bar"));
}
@Before
public void setUp() {
fooRepository.save(new Foo("Foo"));
fooRepository.save(new Foo("Bar"));
}
@Test
public void testFindByName() {
Foo foo = fooRepository.findByName("Bar");
assertThat(foo, notNullValue());
assertThat(foo.getId(), is(2));
}
@Test
public void testFindByName() {
Foo foo = fooRepository.findByName("Bar");
assertThat(foo, notNullValue());
assertThat(foo.getId(), is(2));
}
}