use of org.talend.mdm.repository.core.service.IInteractiveHandler in project tmdm-studio-se by Talend.
the class RepositoryResourceUtilTest method testFindAllViewObjects.
/**
* Test for: findAllViewObjects(ERepositoryObjectType type, boolean useRepositoryViewObject, boolean withDeleted)
*/
@Test
public void testFindAllViewObjects() throws Exception {
boolean withDeleted = false;
boolean useRepositoryViewObject = true;
ERepositoryObjectType mockType = mock(ERepositoryObjectType.class);
IProxyRepositoryFactory mockFactory = mock(IProxyRepositoryFactory.class);
when(CoreRuntimePlugin.getInstance().getProxyRepositoryFactory()).thenReturn(mockFactory);
List<IRepositoryViewObject> viewObjects = new ArrayList<IRepositoryViewObject>();
IRepositoryViewObject mockViewObject = mock(IRepositoryViewObject.class);
Property mockProperty = mock(Property.class);
when(mockViewObject.getProperty()).thenReturn(mockProperty);
when(mockViewObject.getRepositoryObjectType()).thenReturn(mockType);
Item mockItem = mock(Item.class);
when(mockProperty.getItem()).thenReturn(mockItem);
ItemState mockItemState = mock(ItemState.class);
when(mockItemState.isDeleted()).thenReturn(false);
when(mockItem.getState()).thenReturn(mockItemState);
viewObjects.add(mockViewObject);
when(mockFactory.getAll(mockType, withDeleted)).thenReturn(viewObjects);
PowerMockito.mockStatic(InteractiveService.class);
IInteractiveHandler mockHandler = mock(IInteractiveHandler.class);
when(InteractiveService.findHandler(mockType)).thenReturn(mockHandler);
PowerMockito.mockStatic(RepositoryResourceUtil.class);
IRepositoryViewObject mockResultViewObject = mock(IRepositoryViewObject.class);
PowerMockito.when(RepositoryResourceUtil.class, "getCacheViewObject", mockProperty, mockViewObject).thenReturn(mockResultViewObject);
PowerMockito.when(RepositoryResourceUtil.class, "assertViewObject", mockViewObject).thenReturn(mockViewObject);
PowerMockito.doCallRealMethod().when(RepositoryResourceUtil.class, "findAllViewObjects", mockType, useRepositoryViewObject, withDeleted);
List<IRepositoryViewObject> viewObjectss = RepositoryResourceUtil.findAllViewObjects(mockType, useRepositoryViewObject, withDeleted);
assertEquals(1, viewObjectss.size());
PowerMockito.verifyStatic(Mockito.atLeastOnce());
InteractiveService.findHandler(mockType);
}
use of org.talend.mdm.repository.core.service.IInteractiveHandler in project tmdm-studio-se by Talend.
the class RepositoryViewObjectCheckedWidget method getAssociatedObjectCommand.
private List<AbstractDeployCommand> getAssociatedObjectCommand(IRepositoryViewObject viewObj, int cmdType) {
ERepositoryObjectType type = viewObj.getRepositoryObjectType();
CommandManager commandManager = CommandManager.getInstance();
if (type != null) {
IInteractiveHandler handler = InteractiveService.findHandler(type);
if (handler != null) {
List<IRepositoryViewObject> associatedObjects = handler.getAssociatedObjects(viewObj);
if (associatedObjects != null) {
return commandManager.getDeployCommands(associatedObjects, cmdType);
}
}
}
return null;
}
use of org.talend.mdm.repository.core.service.IInteractiveHandler in project tmdm-studio-se by Talend.
the class DeleteCommand method execute.
@Override
public IStatus execute(Object receiver, IProgressMonitor monitor) {
IInteractiveHandler handler = InteractiveService.findHandler(getViewObjectType());
String objectName = getObjLastName();
if (handler != null) {
String typeLabel = handler.getLabel();
monitor.subTask(Messages.bind(Messages._SubTaskTitle, typeLabel));
try {
handler.remove(this);
return DeployStatus.getOKStatus(this, Messages.bind(Messages._OkDeleteStatusMsg, typeLabel, objectName));
} catch (Exception e) {
return getDetailErrorMsg(Messages._ErrorStatusMsg1, typeLabel, objectName, e);
}
} else {
return DeployStatus.getErrorStatus(null, Messages.bind(Messages._ErrorStatusMsg2, objectName));
}
}
use of org.talend.mdm.repository.core.service.IInteractiveHandler in project tmdm-studio-se by Talend.
the class DeployCompoundCommand method getOKStatusMsg.
@Override
protected String getOKStatusMsg() {
ERepositoryObjectType type = getViewObjectType();
String objectName = deployCommand.getObjLastName();
IInteractiveHandler handler = InteractiveService.findHandler(type);
if (handler != null) {
String typeLabel = handler.getLabel();
return Messages.bind(Messages._OkStatusMsg, typeLabel, objectName);
}
return null;
}
Aggregations