| /******************************************************************************* |
| * <copyright> |
| * |
| * Copyright (c) 2005, 2010 SAP AG. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Stefan Dimov - initial API, implementation and documentation |
| * |
| * </copyright> |
| * |
| *******************************************************************************/ |
| package org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature; |
| |
| import static org.easymock.EasyMock.expect; |
| import static org.easymock.EasyMock.isA; |
| import static org.easymock.EasyMock.replay; |
| import static org.junit.Assert.assertNotNull; |
| |
| import org.easymock.EasyMock; |
| import org.eclipse.core.resources.IFile; |
| import org.eclipse.graphiti.features.context.IAddContext; |
| import org.eclipse.jdt.core.JavaCore; |
| import org.eclipse.jpt.jpa.core.JpaProject; |
| import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; |
| import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.OpenMiniatureViewFeature; |
| import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider; |
| import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.JPACreateFactory; |
| import org.junit.Before; |
| import org.junit.Test; |
| |
| public class OpenMiniatureViewFeatureTest { |
| |
| private IJPAEditorFeatureProvider featureProvider; |
| final String TEST_PROJECT = "Test"; |
| private JpaProject jpaProject = null; |
| private JPACreateFactory factory = null; |
| |
| @Before |
| public void setUp() throws Exception{ |
| factory = JPACreateFactory.instance(); |
| jpaProject = factory.createJPAProject(TEST_PROJECT + "_" + System.currentTimeMillis()); |
| assertNotNull(jpaProject); |
| IFile entity = factory.createEntity(jpaProject, "org.eclipse.Entity1"); |
| Thread.sleep(2000); |
| featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class); |
| expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entity)); |
| expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes(); |
| replay(featureProvider); |
| } |
| |
| @Test |
| public void testExecute() { |
| OpenMiniatureViewFeature ft = new OpenMiniatureViewFeature(featureProvider); |
| IAddContext ctx = EasyMock.createMock(IAddContext.class); |
| ft.execute(ctx); |
| } |
| |
| |
| } |