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;
}
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());
}
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;
}
Aggregations