Search in sources :

Example 1 with WSMenuItem

use of org.talend.mdm.repository.model.mdmproperties.WSMenuItem in project tmdm-studio-se by Talend.

the class NewMenuAction method createServerObject.

@Override
protected Item createServerObject(String key) {
    WSMenuItem item = MdmpropertiesFactory.eINSTANCE.createWSMenuItem();
    ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
    item.setState(itemState);
    // 
    WSMenuE menu = newBlankMenu(key);
    item.setWsMenu(menu);
    if (parentItem != null) {
        item.getState().setPath(parentItem.getState().getPath());
        RepositoryResourceUtil.createItem(item, key);
    }
    return item;
}
Also used : WSMenuItem(org.talend.mdm.repository.model.mdmproperties.WSMenuItem) ItemState(org.talend.core.model.properties.ItemState) WSMenuE(org.talend.mdm.repository.model.mdmserverobject.WSMenuE)

Example 2 with WSMenuItem

use of org.talend.mdm.repository.model.mdmproperties.WSMenuItem in project tmdm-studio-se by Talend.

the class NewMenuActionTest method testCreateServerObject.

@Test
public void testCreateServerObject() throws Exception {
    // 
    ContainerItem newItem = MdmpropertiesFactory.eINSTANCE.createContainerItem();
    ContainerItem mockContainerItem = spy(newItem);
    PowerMockito.mockStatic(MDMWorbenchPlugin.class);
    when(MDMWorbenchPlugin.getImageDescriptor(anyString())).thenReturn(mock(ImageDescriptor.class));
    NewMenuAction action = new NewMenuAction();
    NewMenuAction spyAction = spy(action);
    // $NON-NLS-1$
    Whitebox.setInternalState(spyAction, "parentItem", mockContainerItem);
    ItemState itemState = mock(ItemState.class);
    when(mockContainerItem.getState()).thenReturn(itemState);
    // $NON-NLS-1$
    when(mockContainerItem.getState().getPath()).thenReturn("");
    WSMenuItem item = MdmpropertiesFactory.eINSTANCE.createWSMenuItem();
    WSMenuItem spyMenuItem = spy(item);
    Resource mockResource = mock(Resource.class);
    ResourceSet mockResourceSet = mock(ResourceSet.class);
    when(mockResource.getResourceSet()).thenReturn(mockResourceSet);
    when(spyMenuItem.eResource()).thenReturn(mockResource);
    PowerMockito.whenNew(WSMenuItemImpl.class).withNoArguments().thenReturn((WSMenuItemImpl) spyMenuItem);
    // run
    // $NON-NLS-1$
    Item addedItem = spyAction.createServerObject("abc");
    assertThat(addedItem, notNullValue());
}
Also used : WSMenuItem(org.talend.mdm.repository.model.mdmproperties.WSMenuItem) WSMenuItem(org.talend.mdm.repository.model.mdmproperties.WSMenuItem) Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ItemState(org.talend.core.model.properties.ItemState) Resource(org.eclipse.emf.ecore.resource.Resource) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) AbstractSimpleAddActionTest(org.talend.mdm.repository.ui.actions.AbstractSimpleAddActionTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with WSMenuItem

use of org.talend.mdm.repository.model.mdmproperties.WSMenuItem in project tmdm-studio-se by Talend.

the class MenuNodeResourceProvider method save.

@Override
public Resource save(Item item) throws PersistenceException {
    if (item instanceof WSMenuItem) {
        Resource resource = xmiResourceManager.getItemResource(item);
        resource.getContents().clear();
        resource.getContents().add(((WSMenuItem) item).getWsMenu());
        Resource eResource = ((WSMenuItem) item).getWsMenu().eResource();
        return resource;
    }
    return null;
}
Also used : WSMenuItem(org.talend.mdm.repository.model.mdmproperties.WSMenuItem) Resource(org.eclipse.emf.ecore.resource.Resource)

Aggregations

WSMenuItem (org.talend.mdm.repository.model.mdmproperties.WSMenuItem)3 Resource (org.eclipse.emf.ecore.resource.Resource)2 ItemState (org.talend.core.model.properties.ItemState)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 Item (org.talend.core.model.properties.Item)1 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)1 WSMenuE (org.talend.mdm.repository.model.mdmserverobject.WSMenuE)1 AbstractSimpleAddActionTest (org.talend.mdm.repository.ui.actions.AbstractSimpleAddActionTest)1