VmList { public static <T extends Vm> T getById(List<T> vmList, int id) { for (T vm : vmList) { if (vm.getId() == id) { return vm; } } return null; }  static T getById(List<T> vmList, int id); static T getByIdAndUserId(List<T> vmList, int id, int userId);  }
@Test public void testGetVMbyID() { assertNull(VmList.getById(vmList, 0)); assertNull(VmList.getById(vmList, 1)); assertNull(VmList.getById(vmList, 2)); Vm vm1 = new Vm(0, 0, 0, 1, 0, 0, 0, "", null); Vm vm2 = new Vm(1, 0, 0, 1, 0, 0, 0, "", null); Vm vm3 = new Vm(2, 0, 0, 2, 0, 0, 0, "", null); vmList.add(vm1); vmList.add(vm2); vmList.add(vm3); assertSame(vm1, VmList.getById(vmList, 0)); assertSame(vm2, VmList.getById(vmList, 1)); assertSame(vm3, VmList.getById(vmList, 2)); }