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

Refactoring README.md #61

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
401 changes: 156 additions & 245 deletions README.md

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/main/java/io/pillopl/library/catalogue/Book.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Book {
}
}


@Value
class Title {

Expand All @@ -35,7 +34,6 @@ class Title {
}
this.title = title.trim();
}

}

@Value
Expand All @@ -49,4 +47,4 @@ class Author {
}
this.name = name.trim();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ class BookInstance {

static BookInstance instanceOf(Book book, BookType bookType) {
return new BookInstance(book.getBookIsbn(), new BookId(UUID.randomUUID()), bookType);

}
}
1 change: 0 additions & 1 deletion src/main/java/io/pillopl/library/catalogue/BookType.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
public enum BookType {
Restricted, Circulating
}

3 changes: 0 additions & 3 deletions src/main/java/io/pillopl/library/catalogue/Catalogue.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,4 @@ private BookInstance saveAndPublishEvent(BookInstance bookInstance) {
domainEvents.publish(new BookInstanceAddedToCatalogue(bookInstance));
return bookInstance;
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Option<Book> findBy(ISBN isbn) {

}
}

}

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ DataSource dataSource() {
.addScript("create_catalogue_book.sql")
.build();
}
}
}
1 change: 0 additions & 1 deletion src/main/java/io/pillopl/library/catalogue/ISBN.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ class ISBN {
throw new IllegalArgumentException("Wrong ISBN!");
}
this.isbn = isbn.trim();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

public enum BatchResult {
FullSuccess, SomeFailed
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

public enum Result {
Success, Rejection
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Transactional;


@AllArgsConstructor
public class StoreAndForwardDomainEventPublisher implements DomainEvents {

Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/create_catalogue_book.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ CREATE TABLE IF NOT EXISTS catalogue_book (
title VARCHAR(100) NOT NULL,
author VARCHAR(100) NOT NULL);


CREATE TABLE IF NOT EXISTS catalogue_book_instance (
id INTEGER IDENTITY PRIMARY KEY,
isbn VARCHAR(100) NOT NULL,
book_id UUID NOT NULL);

CREATE SEQUENCE catalogue_book_seq;
CREATE SEQUENCE catalogue_book_instance_seq;


18 changes: 15 additions & 3 deletions src/main/resources/create_patron_db.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
CREATE TABLE IF NOT EXISTS patron_database_entity (id INTEGER IDENTITY PRIMARY KEY, patron_type VARCHAR(100) NOT NULL, patron_id UUID UNIQUE);
CREATE TABLE IF NOT EXISTS patron_database_entity (
id INTEGER IDENTITY PRIMARY KEY,
patron_type VARCHAR(100) NOT NULL,
patron_id UUID UNIQUE);

CREATE TABLE IF NOT EXISTS hold_database_entity (id INTEGER IDENTITY PRIMARY KEY, book_id UUID NOT NULL, patron_id UUID NOT NULL, library_branch_id UUID NOT NULL, patron_database_entity INTEGER NOT NULL, till TIMESTAMP NOT NULL);
CREATE TABLE IF NOT EXISTS hold_database_entity (
id INTEGER IDENTITY PRIMARY KEY,
book_id UUID NOT NULL, patron_id UUID NOT NULL,
library_branch_id UUID NOT NULL,
patron_database_entity INTEGER NOT NULL,
till TIMESTAMP NOT NULL);

CREATE TABLE IF NOT EXISTS overdue_checkout_database_entity (id INTEGER IDENTITY PRIMARY KEY, book_id UUID NOT NULL, patron_id UUID NOT NULL, library_branch_id UUID NOT NULL, patron_database_entity INTEGER NOT NULL);
CREATE TABLE IF NOT EXISTS overdue_checkout_database_entity (
id INTEGER IDENTITY PRIMARY KEY,
book_id UUID NOT NULL, patron_id UUID NOT NULL,
library_branch_id UUID NOT NULL,
patron_database_entity INTEGER NOT NULL);
2 changes: 0 additions & 2 deletions src/main/resources/create_sheets_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ id INTEGER IDENTITY PRIMARY KEY,
checked_out_at_branch UUID,
checkout_till TIMESTAMP);


CREATE TABLE IF NOT EXISTS holds_sheet (
id INTEGER IDENTITY PRIMARY KEY,
book_id UUID NOT NULL,
Expand All @@ -25,4 +24,3 @@ id INTEGER IDENTITY PRIMARY KEY,

CREATE SEQUENCE holds_sheet_seq;
CREATE SEQUENCE checkouts_sheet_seq;

Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,4 @@ public class ModularArchitectureTest {
.should()
.dependOnClassesThat()
.resideInAPackage("..lending..");


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class AddBookToCatalogueTest extends Specification {
then:
result.isSuccess()
result.get() == Result.Success

}

def 'should add a new book instance to catalogue'() {
Expand All @@ -38,7 +37,6 @@ class AddBookToCatalogueTest extends Specification {
result.get() == Result.Success
and:
1 * domainEvents.publish(_ as BookInstanceAddedToCatalogue)

}

def 'should reject adding a new book instance to catalogue when book isbn does not exist'() {
Expand All @@ -53,7 +51,6 @@ class AddBookToCatalogueTest extends Specification {
result.get() == Result.Rejection
and:
0 * domainEvents.publish(_ as BookInstanceAddedToCatalogue)

}

def 'should fail when adding a book if database fails'() {
Expand Down Expand Up @@ -81,13 +78,11 @@ class AddBookToCatalogueTest extends Specification {
void databaseWorks() {
catalogueDatabase.saveNew(_ as Book) >> null
catalogueDatabase.saveNew(_ as BookInstance) >> null

}

void databaseDoesNotWork() {
catalogueDatabase.saveNew(_ as Book) >> { (new IllegalStateException()) }
catalogueDatabase.saveNew(_ as BookInstance) >> { (new IllegalStateException()) }

}

void thereIsBookWith(String isbn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class BookTitleAuthorISBNTest extends Specification {
Title title = new Title(" to trim ")
expect:
title.title == "to trim"

}

def "author should be trimmed"() {
Expand Down Expand Up @@ -68,5 +67,3 @@ class BookTitleAuthorISBNTest extends Specification {
thrown(IllegalArgumentException)
}
}


2 changes: 1 addition & 1 deletion src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
<root level="WARN">
<appender-ref ref="STDOUT" />
</root>
</configuration>
</configuration>