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