Question
Hello I need help with this assignment. I need to come up with four black box test methods for describeBooksBy() method of the Library.java class
Hello I need help with this assignment. I need to come up with four black box test methods for describeBooksBy() method of the Library.java class
Thank you!!
The requirements of this assignment are as follows:
- The given NetBeans Java project contains two classes (Book.java and Library.java).
- The Library.java class contains a method (describeBooksBy()). It is the method that you will black-box test.
You will use the NetBeans JUnit framework to develop four black-box test methods for the describeBooksBy() method of the Library.java class.
package bookstore;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
public class Book {
private @Nonnull String author;
private @Nonnull String title;
private @CheckForNull String subtitle;
public @Nonnull String getAuthor() {
return author;
}
public @Nonnull String getSubtitle() {
return subtitle;
}
public @Nonnull String getTitle() {
return title;
}
}
package bookstore;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import javax.annotation.Nonnull;
public class Library {
private final Set
public void addBook(@Nonnull Book newBook) {
if (newBook == null) {
//@Nonnull was not present in the first version, protect against old
//clients which may not know about the constraint
return;
}
books.add(newBook);
}
public @Nonnull Iterable extends String> describeBooksBy(@Nonnull String author) {
List
for (Book b : books) {
if (!author.equals(b.getAuthor())) continue;
result.add(String.format("%s: %d", b.getAuthor(), b.getTitle()));
}
return result;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started