ConsumerPrincipal extends Principal { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final ConsumerPrincipal other = (ConsumerPrincipal) obj; if (this.consumer != other.consumer && (this.consumer == null || !this.consumer.equals(other.consumer))) { return false; } return true; } ConsumerPrincipal(Consumer consumer, Owner owner); Consumer getConsumer(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String getName(); @Override String getType(); @Override boolean hasFullAccess();  }
@Test public void equalsNull() { assertFalse(principal.equals(null)); }
@Test public void equalsOtherObject() { assertFalse(principal.equals(new Object())); }
@Test public void equalsAnotherConsumerPrincipal() { ConsumerPrincipal cp = new ConsumerPrincipal(consumer, o); assertTrue(principal.equals(cp)); }
@Test public void equalsDifferentConsumer() { ConsumerType ctype = new ConsumerType(ConsumerType.ConsumerTypeEnum.SYSTEM); ctype.setId("test-ctype"); Owner newOwner = new Owner("o1"); newOwner.setId("o1-id"); Consumer c = new Consumer("Test Consumer", "test-consumer", newOwner, ctype); ConsumerPrincipal cp = new ConsumerPrincipal(c, o); assertFalse(principal.equals(cp)); }