@Test(dependsOnMethods = {"testInstantiation"}) public void testEqualsAndHashCode() { ShareableResource rc1 = new ShareableResource("foo"); ShareableResource rc2 = new ShareableResource("foo"); ShareableResource rc3 = new ShareableResource("bar"); Assert.assertEquals(rc1, rc2); Assert.assertEquals(rc2, rc2); Assert.assertEquals(rc1.hashCode(), rc2.hashCode()); Assert.assertNotEquals(rc1, rc3); Assert.assertNotEquals(rc3, rc2); Assert.assertNotEquals(rc1.hashCode(), rc3.hashCode()); Assert.assertNotEquals(rc1, "foo"); }
@Override public int hashCode() { return Objects.hash(rcId, vmsConsumption, nodesCapacity); }
ShareableResource implements ModelView { @Override public int hashCode() { return Objects.hash(rcId, vmsConsumption, nodesCapacity); } }
ShareableResource implements ModelView { @Override public int hashCode() { return Objects.hash(rcId, vmsConsumption, nodesCapacity); } ShareableResource(String r);  ShareableResource(String id, int defCapacity, int defConsumption); }
ShareableResource implements ModelView { @Override public int hashCode() { return Objects.hash(rcId, vmsConsumption, nodesCapacity); } ShareableResource(String r);  ShareableResource(String id, int defCapacity, int defConsumption); int getConsumption(VM vm); int getCapacity(Node n); Set<VM> getDefinedVMs(); Set<Node> getDefinedNodes(); ShareableResource setConsumption(VM vm, int val); ShareableResource setConsumption(int val, VM... vms); ShareableResource setCapacity(Node n, int val); ShareableResource setCapacity(int val, Node... nodes); void unset(VM vm); void unset(Node n); void unset(VM... vms); void unset(Node... nodes); boolean consumptionDefined(VM vm); boolean capacityDefined(Node n); @Override String getIdentifier(); static String getIdentifier(String rcId); String getResourceIdentifier(); int getDefaultConsumption(); int getDefaultCapacity(); @Override boolean equals(Object o); @Override int hashCode(); @Override ShareableResource copy(); @Override String toString(); @Override boolean substituteVM(VM oldRef, VM newRef); int sumConsumptions(Collection<VM> ids, boolean undef); int sumCapacities(Collection<Node> ids, boolean undef); static ShareableResource get(Model mo, String id); }
ShareableResource implements ModelView { @Override public int hashCode() { return Objects.hash(rcId, vmsConsumption, nodesCapacity); } ShareableResource(String r);  ShareableResource(String id, int defCapacity, int defConsumption); int getConsumption(VM vm); int getCapacity(Node n); Set<VM> getDefinedVMs(); Set<Node> getDefinedNodes(); ShareableResource setConsumption(VM vm, int val); ShareableResource setConsumption(int val, VM... vms); ShareableResource setCapacity(Node n, int val); ShareableResource setCapacity(int val, Node... nodes); void unset(VM vm); void unset(Node n); void unset(VM... vms); void unset(Node... nodes); boolean consumptionDefined(VM vm); boolean capacityDefined(Node n); @Override String getIdentifier(); static String getIdentifier(String rcId); String getResourceIdentifier(); int getDefaultConsumption(); int getDefaultCapacity(); @Override boolean equals(Object o); @Override int hashCode(); @Override ShareableResource copy(); @Override String toString(); @Override boolean substituteVM(VM oldRef, VM newRef); int sumConsumptions(Collection<VM> ids, boolean undef); int sumCapacities(Collection<Node> ids, boolean undef); static ShareableResource get(Model mo, String id); static final String VIEW_ID_BASE; static final int DEFAULT_NO_VALUE; }