|
|
|
Re: How to test custom ResourceDescriptionStrategy? [message #870036 is a reply to message #866314] |
Sat, 05 May 2012 22:25 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
Oh, that's an easy one. The IAcceptor<T> interface is meant as a marker
interface, such that you no longer have to provide plain collections
that collect results as a parameter. Instead, you specify an IAcceptor,
thus marking the argument as "collecting the results".
You can just instantiate an anonymous instance filling a final
collection variable, such as
final Set<IEObjectDescription> descriptions = newHashSet();
IAcceptor<IEObjectDescription> acceptor = new
IAcceptor<IEObjectDescription>() {
public void accept(IEObjectDescription acceptMe) {
descriptions.add(acceptMe);
}
);
rds.createEObjectDescriptions(c, acceptor);
// do something with 'descriptions'
Am 30.04.12 22:56, schrieb Scott Finnie:
> I have a custom ResourceDescriptionStrategy with overloaded
> createEObjectDescriptions() method and want to unit test it. However I'm
> not sure how to create the IAcceptor<IEObjectDescription>? There's no
> class pre-configured in the module descriptions and I can't seem to find
> one that's not protected. Here's the test code:
>
>
> class TestResourceDescriptionStrategy {
>
> @Inject
> IResourceDescriptions index;
>
> @Inject
> IQualifiedNameProvider qnp;
>
> @Test
> public void testCreateEObjectDescriptions(){
> c = MyDslFactory.eINSTANCE.createClass();
> rds = new MyDslResourceDescriptionStrategy();
>
> //problem: what class to construct acceptor from?
> rds.createEObjectDescriptions(c, acceptor);
>
> QualifiedName qn=qnp.getFullyQualifiedName(c);
> Iterable<IEObjectDescription> descriptions;
> descriptions=index.getExportedObjects(c.eClass(), qn, false);
> //...check there's only one entry in collection
> }
> }
>
>
> Suggestions appreciated for IAcceptor instance (or any comments on test
> approach...).
>
> Thanks.
>
>
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
|
Powered by
FUDForum. Page generated in 0.03804 seconds