Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

[UnitTest] @Self Annotation using Mangeto and a CIF Model within custom Model

Avatar

Level 1

Hi Community, 

 

I'm trying to write my Unit test for a model created to interact with the MagentoGraphqlClient Object. 

My doubt here comes when I need to inject a mocked object using the @Self  annotation.

 

@Self(injectionStrategy = InjectionStrategy.OPTIONAL)
private MagentoGraphqlClient magentoGraphqlClient;

 Also for a CIF Model that is being called within my custom model.

@Self(injectionStrategy = InjectionStrategy.OPTIONAL)
@Via(type = ResourceSuperType.class)
private com.adobe.cq.commerce.core.components.models.productlist.ProductList productList;

 Does anybody have any idea how can I inject these mocked objects and interact with the returning values within my Model?

 

Regards.

3 Replies

Avatar

Level 1

Thanks for sharing this information, I did take a look before but this is not providing too much information about this case.