Search in sources :

Example 1 with WSServiceConfigurationItem

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());
}
Also used : Item(org.talend.core.model.properties.Item) WSServiceConfigurationItem(org.talend.mdm.repository.model.mdmproperties.WSServiceConfigurationItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) WSServiceConfigurationItem(org.talend.mdm.repository.model.mdmproperties.WSServiceConfigurationItem) 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 2 with WSServiceConfigurationItem

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;
}
Also used : WSServiceConfigurationItem(org.talend.mdm.repository.model.mdmproperties.WSServiceConfigurationItem) WSServiceConfigurationE(org.talend.mdm.repository.model.mdmserverobject.WSServiceConfigurationE) ItemState(org.talend.core.model.properties.ItemState)

Example 3 with WSServiceConfigurationItem

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;
}
Also used : WSServiceConfigurationItem(org.talend.mdm.repository.model.mdmproperties.WSServiceConfigurationItem) Resource(org.eclipse.emf.ecore.resource.Resource)

Aggregations

WSServiceConfigurationItem (org.talend.mdm.repository.model.mdmproperties.WSServiceConfigurationItem)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 WSServiceConfigurationE (org.talend.mdm.repository.model.mdmserverobject.WSServiceConfigurationE)1 AbstractSimpleAddActionTest (org.talend.mdm.repository.ui.actions.AbstractSimpleAddActionTest)1