### Question:
SubscriptionResource extends AbstractResource { @POST public VirtualMachineDto subscribe(VirtualMachineDto virtualMachine) { checkSystem(); VirtualMachine vm = vsmService.subscribe(virtualMachine.getPhysicalMachine().getAddress(), virtualMachine .getPhysicalMachine().getType(), virtualMachine.getName()); return toDto(vm); } SubscriptionResource(); @GET VirtualMachinesDto getSubscriptions(
        @QueryParam(VIRTUAL_MACHINE_NAME_QUERY_PARAM) String virtualMachineName); @POST VirtualMachineDto subscribe(VirtualMachineDto virtualMachine); @DELETE @Path(SUBSCRIPTION_PATH) void unsubscribe(@PathParam(SUBSCRIPTION_PARAM) String subscriptionId); static final String SUBSCRIPTIONS_PATH; static final String SUBSCRIPTION_PARAM; static final String SUBSCRIPTION_PATH; }### Answer:
@Test public void test_subscribe() { PhysicalMachineDto pm = monitor("10.60.1.78", Type.HYPERV_301); subscribe(pm, UUID.randomUUID().toString()); }
@Test public void test_subscribeInvalidPhysicalMachine() { monitor("10.60.1.78", Type.HYPERV_301); PhysicalMachineDto unexisting = new PhysicalMachineDto(); unexisting.setId(23); unexisting.setAddress("10.60.1.100"); unexisting.setType(Type.HYPERV_301.name()); try { subscribe(unexisting, UUID.randomUUID().toString()); fail("Physical machine " + unexisting.getAddress() + " should not exist"); } catch (VSMException ex) { assertEquals(ex.getResponse().getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode()); } }