How do I create a JUnit test that tests an abstract code from another class? I have an Abstract class called AbstractCurve and a "producer and consumer curve" that extends the abstract curve. The ConsumerCurve and ProducerCurve are the same but different class name. Here is the code:
public abstract class AbstractCurve {
ArrayList < Point > myCurve = new ArrayList < Point > ();
public AbstractCurve(int np, double m, double b, int dx) {
for (int i = 0; i < np; i++) {
int x = i * dx;
double y = m * x + b;
if (y < 0) throw new IllegalArgumentException();
ArrayList < Point > myCurve = new ArrayList < Point > ();
myCurve.add(new Point(x, y));
}
}
public boolean add(Point p) {
myCurve.add(p);
sort();
return false;
}
public void delete(Point p) {
myCurve.remove(p);
}
public abstract void sort();
public String toString() {
String t = " ";
for (int i = 0; i < myCurve.size(); i++) {
t = t + myCurve.get(i).toString() + " ";
}
return t;
}
public int contains(Point p) {
for (int index = 0; index < myCurve.size(); index++) {
myCurve.equals(index);
}
return -1;
}
}
Consumer:
public class ConsumerCurve extends AbstractCurve{
public ConsumerCurve() {
super(0, 0, 0, 0);
}
public void sort() {}
}