contentFragment Element getValue unit test unsupported operation | Community
Skip to main content
sreenu539
Level 7
Jul 13, 2023 7:22 PM UTC
Solved

contentFragment Element getValue unit test unsupported operation

Hi,

 

any example to unit test 

 

contentElement.getValue().getValue(String[].class);

 

I am getting io.wcm unsupported operation exception, when trying to unit test this specific line of code. 

 

Thanks,

Sri

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
BrianKasingli
BrianKasingliAccepted solution
New Participant
Jul 14, 2023 12:03 AM UTC

Yeah I got this problem too, I fixed it by refactoring the code, and broke it up.

 

 

String[] cfNamesArray = contentFragment.map(cf -> cf.getElement("names")).map(ContentElement::getContent) .filter(StringUtils::isNotEmpty) .map(names -> names.split(",")) .orElse(null);

 

 

4 replies

Tanika02
Level 7
Jul 14, 2023 4:38 AM UTC

Hello @sreenu539 - 

 

I see the same has been reported here https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/java-lang-unsupportedoperationexception-in-junit-test-content/m-p/546188 

 

Looks like these methods are not supported yet with the wcm.io mocking library & I see the issue is listed here https://github.com/wcm-io/io.wcm.testing.aem-mock/issues/15 still in progress.

Translate
BrianKasingli
BrianKasingliAccepted solution
New Participant
Jul 14, 2023 12:03 AM UTC

Yeah I got this problem too, I fixed it by refactoring the code, and broke it up.

 

 

String[] cfNamesArray = contentFragment.map(cf -> cf.getElement("names")).map(ContentElement::getContent) .filter(StringUtils::isNotEmpty) .map(names -> names.split(",")) .orElse(null);

 

 

Translate