use of com.google.example.library.v1.Book in project kripton by xcesco.
the class TestCustomBeanRuntimeErr1 method testContraintViolation.
@Test
public void testContraintViolation() throws InterruptedException, InstantiationException, IllegalAccessException {
this.expectedException(KriptonRuntimeException.class);
BindAppDataSource dataSource = BindAppDataSource.build(DataSourceOptions.builder().inMemory(true).build());
dataSource.getLoanDao().findAllWithUserAndBook().observeForever(new Observer<List<LoanWithUserAndBook>>() {
@Override
public void onChanged(List<LoanWithUserAndBook> t) {
if (t.size() > 0) {
LoanWithUserAndBook bean = t.get(0);
log("Found %s elements", t.size());
assertTrue(bean.bookTitle != null);
assertTrue(bean.userName != null);
assertTrue(bean.startTime != null);
assertTrue(bean.id != null);
}
}
});
dataSource.execute(new Transaction() {
@Override
public TransactionResult onExecute(BindAppDaoFactory daoFactory) {
User user = createUser(daoFactory);
Book book = createBook(daoFactory);
insertLoan(daoFactory, user, book);
insertLoan(daoFactory, user, book);
return TransactionResult.COMMIT;
}
private void insertLoan(BindAppDaoFactory daoFactory, User user, Book book) {
Loan loan = new Loan();
loan.id = UUID.randomUUID().toString();
loan.bookId = book.id;
loan.userId = user.id;
loan.startTime = new Date();
daoFactory.getLoanDao().insertLoan(loan);
}
private Book createBook(BindAppDaoFactory daoFactory) {
Book book = new Book();
book.id = UUID.randomUUID().toString();
book.title = "Never Ending Story #" + (counter++);
daoFactory.getBookDao().insertBook(book);
return book;
}
private User createUser(BindAppDaoFactory daoFactory) {
User user = new User();
user.id = UUID.randomUUID().toString();
user.age = 24;
user.name = "Fox";
user.lastName = "Mulder";
daoFactory.getUserDao().insertUser(user);
return user;
}
});
KriptonLibrary.getExecutorService().awaitTermination(4, TimeUnit.SECONDS);
}
use of com.google.example.library.v1.Book in project java_1_sunday_january_2022_online by javagurulv.
the class BookDemo method main.
public static void main(String[] args) {
Book myBook = new Book("Principles");
String bookTitle = myBook.getTitle();
System.out.println("Book title = " + bookTitle);
}
use of com.google.example.library.v1.Book in project pgr112oop by bogdanmarculescu.
the class SomeExplanations method forEachExample.
public void forEachExample() {
BookRegister br = initializeBookRegister();
ArrayList<Book> books = br.allRegisteredBooks();
ArrayList<String> authorNames = new ArrayList<>();
for (Book bok : books) {
authorNames.add(bok.getAuthor());
books.indexOf(bok);
}
}
use of com.google.example.library.v1.Book in project pgr112oop by bogdanmarculescu.
the class SomeExplanations method initializeBookRegister.
public BookRegister initializeBookRegister() {
BookRegister br = new BookRegister();
br.addBook(new Book("Dune", "Frank Herbert", 750, Genre.OTHER));
br.addBook(new Book("Fellowship of the Ring", "J.R.R. Tolkien", 750, Genre.FANTASY));
br.addBook(new Book("The Two Towers", "J.R.R. Tolkien", 750, Genre.FANTASY));
br.addBook(new Book("Return of the King", "J.R.R. Tolkien", 750, Genre.FANTASY));
br.addBook(new Book("Guards! Guards!", "Terry Pratchett", 750, Genre.FANTASY));
return br;
}
use of com.google.example.library.v1.Book in project gapic-generator-java by googleapis.
the class SyncGetBook method syncGetBook.
public static void syncGetBook() throws Exception {
// It may require modifications to work in your environment.
try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
GetBookRequest request = GetBookRequest.newBuilder().setName(BookName.of("[SHELF]", "[BOOK]").toString()).build();
Book response = libraryServiceClient.getBook(request);
}
}
Aggregations