Checkpoint
This commit is contained in:
parent
f006de84f2
commit
eadbcc976b
26
buisnesslogic/src/main/java/com/plannaplan/Book.java
Normal file
26
buisnesslogic/src/main/java/com/plannaplan/Book.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package com.plannaplan;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Book {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// standard constructors
|
||||||
|
|
||||||
|
// standard getters and setters
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.plannaplan;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface BookRepository extends JpaRepository<Book, Long> {
|
||||||
|
}
|
17
buisnesslogic/src/main/java/com/plannaplan/BookService.java
Normal file
17
buisnesslogic/src/main/java/com/plannaplan/BookService.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package com.plannaplan;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class BookService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BookRepository bookRepository;
|
||||||
|
|
||||||
|
public List<Book> list() {
|
||||||
|
return bookRepository.findAll();
|
||||||
|
}
|
||||||
|
}
|
@ -1,20 +1,22 @@
|
|||||||
package com.plannaplan;
|
package com.plannaplan;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit test for simple App.
|
* Unit test for simple App.
|
||||||
*/
|
*/
|
||||||
public class AppTest
|
public class AppTest {
|
||||||
{
|
@Autowired
|
||||||
/**
|
private BookService bookService;
|
||||||
* Rigorous Test :-)
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldAnswerWithTrue()
|
public void whenApplicationStarts_thenHibernateCreatesInitialRecords() {
|
||||||
{
|
List<Book> books = bookService.list();
|
||||||
assertTrue( true );
|
|
||||||
|
Assert.assertEquals(books.size(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user