@Test
public void testCompare() {

    int id = 5;
    TransactionType transactionType = new TransactionType();
    Date transactionTime = new Date();
    double transactionAmount = 100.0;
    boolean paidOut = true;
    Transaction bean = new Transaction(id, transactionType, transactionTime, transactionAmount, paidOut);
    Transaction beanCopy = new Transaction(id, transactionType, transactionTime, transactionAmount, paidOut);
    Set<Transaction> set = new HashSet<>();
    set.add(bean);
    assertTrue(set.contains(bean));
    Transaction emptyBean = new Transaction();
    set.add(emptyBean);
    assertTrue(set.contains(emptyBean));
    assertNotEquals(bean, null);
    assertEquals(bean, beanCopy);
    assertNotEquals(bean, emptyBean);
    assertNotEquals(emptyBean, bean);
    Transaction beanDifferentAmount = new Transaction(id, transactionType, transactionTime, 102.0, paidOut);
    assertNotEquals(bean, beanDifferentAmount);
    final Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DATE, -1);
    Transaction beanDifferentTime = new Transaction(id, transactionType, calendar.getTime(), transactionAmount, paidOut);
    assertNotEquals(bean, beanDifferentTime);
    Transaction beanNullTime1 = new Transaction(id, transactionType, null, transactionAmount, paidOut);
    assertNotEquals(bean, beanNullTime1);
    Transaction beanNullTime2 = new Transaction(id, transactionType, null, transactionAmount, paidOut);
    assertEquals(beanNullTime1, beanNullTime2);
    assertNotEquals(beanNullTime1, bean);
    Transaction beanWithNullType1 = new Transaction(id, null, transactionTime, transactionAmount, paidOut);
    assertNotEquals(beanWithNullType1, bean);
    Transaction beanWithNullType2 = new Transaction(id, null, transactionTime, transactionAmount, paidOut);
    assertEquals(beanWithNullType1, beanWithNullType2);
    TransactionType differentType = new TransactionType(1, "type", null, true, false);
    Transaction beanWithDifferentType = new Transaction(id, differentType, transactionTime, transactionAmount, paidOut);
    assertNotEquals(bean, beanWithDifferentType);
    assertThat(bean.toString()).startsWith("Transaction [id=");
}