Search in sources :

Example 1 with AllEntitiesProcessor

use of org.hibernate.eclipse.jdt.ui.internal.jpa.process.AllEntitiesProcessor in project jbosstools-hibernate by jbosstools.

the class JPAMapMockTests method testMockSave.

public void testMockSave() {
    final IPreferenceStore preferenceStore = context.mock(IPreferenceStore.class);
    final AllEntitiesProcessor allEntitiesProcessor = new AllEntitiesProcessor();
    allEntitiesProcessor.setAnnotationStyle(AnnotStyle.AUTO);
    allEntitiesProcessor.setPreferenceStore(preferenceStore);
    context.checking(new Expectations() {

        {
            oneOf(preferenceStore).setValue(AllEntitiesProcessor.storePropertyName, 2);
            oneOf(preferenceStore).setValue(AllEntitiesProcessor.storeDefaultStrLength, 255);
            oneOf(preferenceStore).setValue(AllEntitiesProcessor.storeEnableOptLock, false);
        }
    });
    allEntitiesProcessor.savePreferences();
    context.assertIsSatisfied();
    allEntitiesProcessor.setAnnotationStyle(null);
    context.checking(new Expectations() {

        {
            oneOf(preferenceStore).setValue(AllEntitiesProcessor.storePropertyName, 0);
            oneOf(preferenceStore).setValue(AllEntitiesProcessor.storeDefaultStrLength, 255);
            oneOf(preferenceStore).setValue(AllEntitiesProcessor.storeEnableOptLock, false);
        }
    });
    allEntitiesProcessor.savePreferences();
    context.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) AllEntitiesProcessor(org.hibernate.eclipse.jdt.ui.internal.jpa.process.AllEntitiesProcessor) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 2 with AllEntitiesProcessor

use of org.hibernate.eclipse.jdt.ui.internal.jpa.process.AllEntitiesProcessor in project jbosstools-hibernate by jbosstools.

the class JPAMapMockTests method testJPAMapToolActor.

public void testJPAMapToolActor() {
    final JPAMapToolActor jpaMapToolActor = new JPAMapToolActor();
    final AllEntitiesProcessor allEntitiesProcessor = context.mock(AllEntitiesProcessor.class);
    final AllEntitiesInfoCollector allEntitiesInfoCollector = context.mock(AllEntitiesInfoCollector.class);
    final ISelection selection = context.mock(ISelection.class);
    final ICompilationUnit compilationUnit = context.mock(ICompilationUnit.class);
    final IJavaProject javaProject = context.mock(IJavaProject.class);
    jpaMapToolActor.setAllEntitiesProcessor(allEntitiesProcessor);
    jpaMapToolActor.setAllEntitiesInfoCollector(allEntitiesInfoCollector);
    jpaMapToolActor.setSelection(selection);
    final IStructuredSelection selection2Update = new StructuredSelection();
    context.checking(new Expectations() {

        {
            exactly(1).of(allEntitiesProcessor).modify(new HashMap<String, EntityInfo>(), true, selection2Update);
        }
    });
    jpaMapToolActor.updateSelected(Integer.MAX_VALUE);
    context.assertIsSatisfied();
    jpaMapToolActor.setSelection(null);
    Set<ICompilationUnit> selectionCU = new HashSet<ICompilationUnit>();
    selectionCU.add(compilationUnit);
    jpaMapToolActor.setSelectionCU(selectionCU);
    // $NON-NLS-1$
    final Sequence sequence = context.sequence("updateSelected");
    context.checking(new Expectations() {

        {
            allowing(compilationUnit).getJavaProject();
            inSequence(sequence);
            will(returnValue(javaProject));
            allowing(allEntitiesInfoCollector).initCollector();
            inSequence(sequence);
            allowing(allEntitiesInfoCollector).collect(compilationUnit, Integer.MAX_VALUE);
            inSequence(sequence);
            allowing(allEntitiesInfoCollector).resolveRelations();
            inSequence(sequence);
            allowing(allEntitiesInfoCollector).getNonAbstractCUNumber();
            inSequence(sequence);
            will(returnValue(2));
            allowing(allEntitiesInfoCollector).getNonInterfaceCUNumber();
            inSequence(sequence);
            will(returnValue(2));
            allowing(allEntitiesInfoCollector).getAnnotationStylePreference();
            inSequence(sequence);
            will(returnValue(AnnotStyle.GETTERS));
            allowing(allEntitiesProcessor).setAnnotationStylePreference(AnnotStyle.GETTERS);
            inSequence(sequence);
            allowing(allEntitiesInfoCollector).getMapCUs_Info();
            inSequence(sequence);
            will(returnValue(null));
            allowing(allEntitiesProcessor).modify(null, true, null);
            inSequence(sequence);
            allowing(allEntitiesProcessor).savePreferences();
            inSequence(sequence);
            exactly(1).of(allEntitiesProcessor).modify(null, true, selection2Update);
        }
    });
    jpaMapToolActor.updateSelected(Integer.MAX_VALUE);
    context.assertIsSatisfied();
/**
 * /
 *		jpaMapToolActor.clearSelectionCU();
 *		jpaMapToolActor.addCompilationUnit(compilationUnit);
 *		jpaMapToolActor.addCompilationUnit(compilationUnit);
 *        context.checking(new Expectations() {{
 *        	jpaMapToolActor.expects(once()).method("updateSelectedItems").with(eq(selection));
 *            one(authorizedPurchaserManager).retrievePurchasers(user.getId());
 *            will(returnValue(Collections.emptyList()));
 *
 *            allowing(securityContext).getAuthentication();
 *            will(returnValue(authentication));
 *        }});
 *        jpaMapToolActor.updateOpen();
 *        /*
 */
}
Also used : Expectations(org.jmock.Expectations) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) HashMap(java.util.HashMap) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Sequence(org.jmock.Sequence) JPAMapToolActor(org.hibernate.eclipse.jdt.ui.internal.jpa.actions.JPAMapToolActor) AllEntitiesProcessor(org.hibernate.eclipse.jdt.ui.internal.jpa.process.AllEntitiesProcessor) IJavaProject(org.eclipse.jdt.core.IJavaProject) AllEntitiesInfoCollector(org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector) ISelection(org.eclipse.jface.viewers.ISelection) HashSet(java.util.HashSet)

Aggregations

AllEntitiesProcessor (org.hibernate.eclipse.jdt.ui.internal.jpa.process.AllEntitiesProcessor)2 Expectations (org.jmock.Expectations)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 JPAMapToolActor (org.hibernate.eclipse.jdt.ui.internal.jpa.actions.JPAMapToolActor)1 AllEntitiesInfoCollector (org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector)1 Sequence (org.jmock.Sequence)1