use of org.talend.mdm.repository.model.mdmproperties.WSServiceConfigurationItem in project tmdm-studio-se by Talend.
the class NewServiceConfigurationActionTest method testCreateServerObject.
@Test
public void testCreateServerObject() throws Exception {
// $NON-NLS-1$
stub(method(ServiceConfigrationMainPage.class, "checkValidXML")).toReturn(null);
// $NON-NLS-1$ //$NON-NLS-2$
stub(method(ServiceConfigrationMainPage.class, "formartXml", String.class)).toReturn("");
//
ContainerItem newItem = MdmpropertiesFactory.eINSTANCE.createContainerItem();
ContainerItem mockContainerItem = spy(newItem);
PowerMockito.mockStatic(MDMWorbenchPlugin.class);
when(MDMWorbenchPlugin.getImageDescriptor(anyString())).thenReturn(mock(ImageDescriptor.class));
NewServiceConfigurationAction action = new NewServiceConfigurationAction();
NewServiceConfigurationAction 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("");
WSServiceConfigurationItem item = MdmpropertiesFactory.eINSTANCE.createWSServiceConfigurationItem();
WSServiceConfigurationItem spyServiceConfigItem = spy(item);
Resource mockResource = mock(Resource.class);
ResourceSet mockResourceSet = mock(ResourceSet.class);
when(mockResource.getResourceSet()).thenReturn(mockResourceSet);
when(spyServiceConfigItem.eResource()).thenReturn(mockResource);
PowerMockito.whenNew(WSServiceConfigurationItemImpl.class).withNoArguments().thenReturn((WSServiceConfigurationItemImpl) spyServiceConfigItem);
// run
// $NON-NLS-1$
Item addedItem = spyAction.createServerObject("abc");
assertThat(addedItem, notNullValue());
}
use of org.talend.mdm.repository.model.mdmproperties.WSServiceConfigurationItem in project tmdm-studio-se by Talend.
the class NewServiceConfigurationAction method createServerObject.
@Override
protected Item createServerObject(String key) {
WSServiceConfigurationItem item = MdmpropertiesFactory.eINSTANCE.createWSServiceConfigurationItem();
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
item.setState(itemState);
WSServiceConfigurationE serConfig = newServiceConfiguration(key);
item.setWsServiceConfiguration(serConfig);
if (parentItem != null) {
item.getState().setPath(parentItem.getState().getPath());
RepositoryResourceUtil.createItem(item, key);
}
return item;
}
use of org.talend.mdm.repository.model.mdmproperties.WSServiceConfigurationItem in project tmdm-studio-se by Talend.
the class ServiceConfigurationNodeResourceProvider method save.
@Override
public Resource save(Item item) throws PersistenceException {
if (item instanceof WSServiceConfigurationItem) {
Resource resource = xmiResourceManager.getItemResource(item);
resource.getContents().clear();
resource.getContents().add(((WSServiceConfigurationItem) item).getWsServiceConfiguration());
Resource eResource = ((WSServiceConfigurationItem) item).getWsServiceConfiguration().eResource();
return resource;
}
return null;
}
Aggregations