私は2つのListを操作してcontains()を使用しようとしています。私は大会を壊すことはありませんが、私のクラスの使用法には含まれています。Javaは同じ値をアサートしますがエラーが発生しました
Items.class
class Items implements Comparable<Items> {
private String name;
private Date date;
private Lib.CLASSENUM type;
public getDate();
public setDate();
....
public compareTo(Items o) {
...
}
}
Test.class
List<Items> actualList;
List<Items> expectedList;
public setup() {
actualList = new ArrayList<>();
expectedList = new ArrayList<>();
}
class Tests {
@Test
public void statusCheckValidatingRedLinePromotionItemsTest() {
//this just sets the two ArrayList to clear
clearProductMaps();
Items goodsItem = new Items();
goodsItem.setName("Product_A");
goodsItem.setPrice(4.10);
goodsItem.setStatus(Lib.CLASSENUM.ORIGINAL);
goodsItem.setDate(date);
actualList.add(goodsItem);
goodsItem = new Items();
goodsItem.settName("Product_A");
goodsItem.setPrice(3.70);
goodsItem.setStatus(Lib.CLASSENUM.PROMO);
date = calendar.getTime();
goodsItem.setDate(date);
actualList.add(goodsItem);
goodsItem = new Items();
goodsItem.setName("Product_A");
goodsItem.setPrice(3.70);
goodsItem.setDate(date);
goodsItem.setStatus(Lib.CLASSENUM.PROMO);
expectedList.add(goodsItem);
assertTrue(expectedGoods.get(0).contains(actualList.get(0));
}
ザ・が含まれているではありません、本当すべきですか? (O == nullの電子== nullの?:o.equals(e)参照)
は、ソートの期限が過ぎているため、実行時またはコンパイル時に上記の編集時にエラーが表示されませんでした。 –