Search in sources :

Example 6 with MacPool

use of org.ovirt.engine.api.model.MacPool in project ovirt-engine by oVirt.

the class BackendMacPoolsResourceTest method doTestBadAddMacPool.

private void doTestBadAddMacPool(boolean valid, boolean success, String detail) throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.AddMacPool, MacPoolParameters.class, new String[] {}, new Object[] {}, valid, success));
    MacPool model = getModel(0);
    try {
        collection.add(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyFault(wae, detail);
    }
}
Also used : MacPoolParameters(org.ovirt.engine.core.common.action.MacPoolParameters) MacPool(org.ovirt.engine.api.model.MacPool) WebApplicationException(javax.ws.rs.WebApplicationException)

Example 7 with MacPool

use of org.ovirt.engine.api.model.MacPool in project ovirt-engine by oVirt.

the class BackendMacPoolsResourceTest method testAddMacPool.

@Test
public void testAddMacPool() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpCreationExpectations(ActionType.AddMacPool, MacPoolParameters.class, new String[] {}, new Object[] {}, true, true, GUIDS[0], QueryType.GetMacPoolById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { Guid.Empty }, getEntity(0));
    MacPool model = getModel(0);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof MacPool);
    verifyModel((MacPool) response.getEntity(), 0);
}
Also used : Response(javax.ws.rs.core.Response) MacPool(org.ovirt.engine.api.model.MacPool) Test(org.junit.Test)

Example 8 with MacPool

use of org.ovirt.engine.api.model.MacPool in project ovirt-engine by oVirt.

the class DataCenterMapper method map.

@Mapping(from = StoragePool.class, to = DataCenter.class)
public static DataCenter map(StoragePool entity, DataCenter template) {
    DataCenter model = template != null ? template : new DataCenter();
    model.setId(entity.getId().toString());
    model.setName(entity.getName());
    model.setLocal(entity.isLocal());
    if (!StringUtils.isEmpty(entity.getdescription())) {
        model.setDescription(entity.getdescription());
    }
    if (!StringUtils.isEmpty(entity.getComment())) {
        model.setComment(entity.getComment());
    }
    if (entity.getStatus() != null) {
        model.setStatus(mapDataCenterStatus(entity.getStatus()));
    }
    if (entity.getCompatibilityVersion() != null) {
        model.setVersion(VersionMapper.map(entity.getCompatibilityVersion()));
    }
    if (entity.getStoragePoolFormatType() != null) {
        StorageFormat storageFormat = StorageFormatMapper.map(entity.getStoragePoolFormatType(), null);
        if (storageFormat != null) {
            model.setStorageFormat(storageFormat);
        }
    }
    if (entity.getMacPoolId() != null) {
        model.setMacPool(new MacPool());
        model.getMacPool().setId(entity.getMacPoolId().toString());
    }
    if (entity.getQuotaEnforcementType() != null) {
        model.setQuotaMode(map(entity.getQuotaEnforcementType()));
    }
    return model;
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) MacPool(org.ovirt.engine.api.model.MacPool) StorageFormat(org.ovirt.engine.api.model.StorageFormat)

Aggregations

MacPool (org.ovirt.engine.api.model.MacPool)8 WebApplicationException (javax.ws.rs.WebApplicationException)3 Test (org.junit.Test)3 Response (javax.ws.rs.core.Response)1 DataCenter (org.ovirt.engine.api.model.DataCenter)1 Ranges (org.ovirt.engine.api.model.Ranges)1 StorageFormat (org.ovirt.engine.api.model.StorageFormat)1 V3MacPool (org.ovirt.engine.api.v3.types.V3MacPool)1 MacPoolParameters (org.ovirt.engine.core.common.action.MacPoolParameters)1