### Question:
Provisioner { public int tryRemoveTenantAssignments(String tenantId, int numToRemove) { if (assignments.containsKey(tenantId)) { int currentVal = assignments.get(tenantId); int actualRemoved = Math.min(numToRemove, currentVal); if (actualRemoved == currentVal) { assignments.remove(tenantId); } else { assignments.put(tenantId, currentVal - numToRemove); } capacityFree += actualRemoved; return actualRemoved; } return 0; } Provisioner(String id, String host, Integer port, Integer capacityTotal, Map<String, Integer> usage,
                     Map<String, Integer> assignments); String getId(); String getHost(); int getPort(); int getCapacityTotal(); int getCapacityFree(); Map<String, Integer> getUsage(); Set<String> getAssignedTenants(); Set<String> getLiveTenants(); void removeTenantAssignments(String tenantId); int tryAddTenantAssignments(String tenantId, int numToAdd); int tryRemoveTenantAssignments(String tenantId, int numToRemove); int getAssignedWorkers(String tenantId); int getLiveWorkers(String tenantId); void setUsage(Map<String, Integer> usage); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testTryRemoveTenantAssignments() { Provisioner provisioner = new Provisioner( "id", "host", 12345, 100, ImmutableMap.<String, Integer>of("t1", 5, "t2", 10, "t3", 20), ImmutableMap.<String, Integer>of("t1", 25, "t2", 50, "t3", 25) ); Assert.assertEquals(0, provisioner.getCapacityFree()); Assert.assertEquals(25, provisioner.getAssignedWorkers("t1")); Assert.assertEquals(50, provisioner.getAssignedWorkers("t2")); Assert.assertEquals(25, provisioner.getAssignedWorkers("t3")); Assert.assertEquals(0, provisioner.tryRemoveTenantAssignments("t4", 10)); Assert.assertEquals(0, provisioner.getCapacityFree()); Assert.assertEquals(25, provisioner.getAssignedWorkers("t1")); Assert.assertEquals(50, provisioner.getAssignedWorkers("t2")); Assert.assertEquals(25, provisioner.getAssignedWorkers("t3")); Assert.assertEquals(5, provisioner.tryRemoveTenantAssignments("t1", 5)); Assert.assertEquals(5, provisioner.getCapacityFree()); Assert.assertEquals(20, provisioner.getAssignedWorkers("t1")); Assert.assertEquals(50, provisioner.getAssignedWorkers("t2")); Assert.assertEquals(25, provisioner.getAssignedWorkers("t3")); Assert.assertEquals(20, provisioner.tryRemoveTenantAssignments("t1", 25)); Assert.assertEquals(25, provisioner.getCapacityFree()); Assert.assertEquals(0, provisioner.getAssignedWorkers("t1")); Assert.assertEquals(50, provisioner.getAssignedWorkers("t2")); Assert.assertEquals(25, provisioner.getAssignedWorkers("t3")); }