Search in sources :

Example 1 with DiskContentType

use of org.ovirt.engine.core.common.businessentities.storage.DiskContentType in project ovirt-engine by oVirt.

the class DiskOperationsValidatorTest method testDisallowedOperations.

@Test
public void testDisallowedOperations() {
    Disk disk = new DiskImage();
    for (Map.Entry<ActionType, List<DiskContentType>> entry : DiskOperationsValidator.allowedCommandsOnTypes.entrySet()) {
        EnumSet<DiskContentType> allowedTypes = EnumSet.copyOf(entry.getValue());
        EnumSet<DiskContentType> disallowedTypes = EnumSet.complementOf(allowedTypes);
        if (disallowedTypes.isEmpty()) {
            continue;
        }
        disk.setContentType(disallowedTypes.iterator().next());
        DiskOperationsValidator validator = new DiskOperationsValidator(disk);
        assertThat(validator.isOperationAllowedOnDisk(entry.getKey()), failsWith(EngineMessage.ACTION_TYPE_FAILED_DISK_CONTENT_TYPE_NOT_SUPPORTED_FOR_OPERATION, String.format("$diskContentType %s", disk.getContentType())));
    }
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) DiskContentType(org.ovirt.engine.core.common.businessentities.storage.DiskContentType) List(java.util.List) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Map(java.util.Map) Test(org.junit.Test)

Example 2 with DiskContentType

use of org.ovirt.engine.core.common.businessentities.storage.DiskContentType in project ovirt-engine by oVirt.

the class DisksContentTypeRadioGroup method getRadioGroupPanel.

private Widget getRadioGroupPanel() {
    buttonToType = new LinkedHashMap<>();
    // $NON-NLS-1$
    RadioButton allButton = new RadioButton(BUTTON_GROUP_NAME);
    buttonToType.put(allButton, null);
    allButton.setText(constants.allDisksLabel());
    for (DiskContentType contentType : DiskContentType.values()) {
        // $NON-NLS-1$
        RadioButton button = new RadioButton(BUTTON_GROUP_NAME);
        buttonToType.put(button, contentType);
    }
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.setDataToggle(Toggle.BUTTONS);
    buttonToType.entrySet().forEach(e -> {
        buttonGroup.add(e.getKey());
        e.getKey().addClickHandler(event -> fireChangeHandlers(e.getValue()));
    });
    setDiskContentType(null);
    localize();
    // $NON-NLS-1$
    buttonGroup.addStyleName("disk-type-buttons-group");
    return buttonGroup;
}
Also used : DiskContentType(org.ovirt.engine.core.common.businessentities.storage.DiskContentType) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) RadioButton(org.gwtbootstrap3.client.ui.RadioButton)

Aggregations

DiskContentType (org.ovirt.engine.core.common.businessentities.storage.DiskContentType)2 List (java.util.List)1 Map (java.util.Map)1 ButtonGroup (org.gwtbootstrap3.client.ui.ButtonGroup)1 RadioButton (org.gwtbootstrap3.client.ui.RadioButton)1 Test (org.junit.Test)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)1 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)1