Search in sources :

Example 16 with ContainerItem

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

the class NewDataContainerActionTest 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));
    NewDataContainerAction action = new NewDataContainerAction();
    NewDataContainerAction 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("");
    WSDataClusterItem item = MdmpropertiesFactory.eINSTANCE.createWSDataClusterItem();
    WSDataClusterItem spyClusterItem = spy(item);
    Resource mockResource = mock(Resource.class);
    ResourceSet mockResourceSet = mock(ResourceSet.class);
    when(mockResource.getResourceSet()).thenReturn(mockResourceSet);
    when(spyClusterItem.eResource()).thenReturn(mockResource);
    PowerMockito.whenNew(WSDataClusterItemImpl.class).withNoArguments().thenReturn((WSDataClusterItemImpl) spyClusterItem);
    // run
    // $NON-NLS-1$
    Item addedItem = spyAction.createServerObject("abc");
    assertThat(addedItem, notNullValue());
}
Also used : WSDataClusterItem(org.talend.mdm.repository.model.mdmproperties.WSDataClusterItem) 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) WSDataClusterItem(org.talend.mdm.repository.model.mdmproperties.WSDataClusterItem) 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 17 with ContainerItem

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

the class NewDataModelActionTest 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));
    IMatchRuleMapInfoService mapInfoService = mock(IMatchRuleMapInfoService.class);
    PowerMockito.mockStatic(ServiceUtil.class);
    PowerMockito.when(ServiceUtil.getService(IMatchRuleMapInfoService.class)).thenReturn(mapInfoService);
    // new action
    NewDataModelAction action = new NewDataModelAction();
    NewDataModelAction 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("");
    WSDataModelItem item = MdmpropertiesFactory.eINSTANCE.createWSDataModelItem();
    WSDataModelItem spyModelItem = spy(item);
    Resource mockResource = mock(Resource.class);
    ResourceSet mockResourceSet = mock(ResourceSet.class);
    when(mockResource.getResourceSet()).thenReturn(mockResourceSet);
    when(spyModelItem.eResource()).thenReturn(mockResource);
    PowerMockito.whenNew(WSDataModelItemImpl.class).withNoArguments().thenReturn((WSDataModelItemImpl) spyModelItem);
    // run
    // $NON-NLS-1$
    Item addedItem = spyAction.createServerObject("abc");
    assertThat(addedItem, notNullValue());
}
Also used : WSDataModelItem(org.talend.mdm.repository.model.mdmproperties.WSDataModelItem) 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) WSDataModelItem(org.talend.mdm.repository.model.mdmproperties.WSDataModelItem) Resource(org.eclipse.emf.ecore.resource.Resource) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IMatchRuleMapInfoService(org.talend.mdm.repository.core.service.IMatchRuleMapInfoService) 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 18 with ContainerItem

use of org.talend.mdm.repository.model.mdmproperties.ContainerItem 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 19 with ContainerItem

use of org.talend.mdm.repository.model.mdmproperties.ContainerItem 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 20 with ContainerItem

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

the class NewTriggerActionTest 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));
    NewTriggerAction action = new NewTriggerAction();
    NewTriggerAction 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("");
    WSRoutingRuleItem item = MdmpropertiesFactory.eINSTANCE.createWSRoutingRuleItem();
    WSRoutingRuleItem spyRoutingRuleItem = spy(item);
    Resource mockResource = mock(Resource.class);
    ResourceSet mockResourceSet = mock(ResourceSet.class);
    when(mockResource.getResourceSet()).thenReturn(mockResourceSet);
    when(spyRoutingRuleItem.eResource()).thenReturn(mockResource);
    PowerMockito.whenNew(WSRoutingRuleItemImpl.class).withNoArguments().thenReturn((WSRoutingRuleItemImpl) spyRoutingRuleItem);
    // run
    // $NON-NLS-1$
    Item addedItem = spyAction.createServerObject("abc");
    assertThat(addedItem, notNullValue());
}
Also used : Item(org.talend.core.model.properties.Item) WSRoutingRuleItem(org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem) 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) WSRoutingRuleItem(org.talend.mdm.repository.model.mdmproperties.WSRoutingRuleItem) AbstractSimpleAddActionTest(org.talend.mdm.repository.ui.actions.AbstractSimpleAddActionTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)46 Item (org.talend.core.model.properties.Item)28 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)24 ItemState (org.talend.core.model.properties.ItemState)18 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)16 Test (org.junit.Test)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)11 FolderRepositoryObject (org.talend.mdm.repository.models.FolderRepositoryObject)11 Property (org.talend.core.model.properties.Property)10 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)9 Resource (org.eclipse.emf.ecore.resource.Resource)8 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)8 AbstractSimpleAddActionTest (org.talend.mdm.repository.ui.actions.AbstractSimpleAddActionTest)8 FolderType (org.talend.core.model.properties.FolderType)6 FolderItem (org.talend.core.model.properties.FolderItem)5 Path (org.eclipse.core.runtime.Path)4 PersistenceException (org.talend.commons.exception.PersistenceException)4 WSDataModelItem (org.talend.mdm.repository.model.mdmproperties.WSDataModelItem)4 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)4