Esempio n. 1
0
  @Test
  public void testNicLinks() throws Exception {
    Nic nic = new Nic();
    nic.setId(NIC_ID);

    nic.setVm(new Vm());
    nic.getVm().setId(VM_ID);

    LinkHelper.addLinks(nic);

    assertEquals(NIC_HREF, nic.getHref());
  }
  @Test
  public void testAddIncompleteParameters() throws Exception {
    Nic model = new Nic();
    model.setName(null);

    setUriInfo(setUpBasicUriExpectations());
    try {
      collection.add(model);
      fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
      verifyIncompleteException(wae, "Nic", "add", "name");
    }
  }
 @Override
 public Nic addParents(Nic nic) {
   InstanceType instanceType = new InstanceType();
   instanceType.setId(instanceTypeId.toString());
   nic.setInstanceType(instanceType);
   return nic;
 }
 public Response add(Nic nic) {
   validateEnums(Nic.class, nic);
   validateParameters(nic, "name");
   return performCreate(
       VdcActionType.AddVmTemplateInterface,
       new AddVmTemplateInterfaceParameters(instanceTypeId, map(nic)),
       new NicResolver(nic.getName()));
 }
 static void verifyModelSpecific(Nic model, int index) {
   assertEquals(GUIDS[index].toString(), model.getId());
   assertEquals(NAMES[index].toString(), model.getName());
   assertTrue(model.isSetVm());
   assertEquals(INSTANCE_TYPE_ID.toString(), model.getVm().getId());
   assertTrue(model.isSetMac());
   assertEquals(ADDRESSES[2].toString(), model.getMac().getAddress());
 }
 static Nic getModel(int index) {
   Nic model = new Nic();
   model.setName(NAMES[index]);
   model.setInterface(NicInterface.RTL8139_VIRTIO.value());
   return model;
 }