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