Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement MockContentFragment_ContentElement_Structured getValue() me… #26

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

koenkicken
Copy link
Contributor

fixes #15

@stefanseifert
Copy link
Member

stefanseifert commented Nov 21, 2023

thanks for the PR!

it currently does not compile against AEM 6.5.7 API, which is the oldest version we support. however, this should not be a problem to be compatible, you have to remove some @Override annotations for the methods which were not present and that version of the AEM API - the classes itself are present already. with this it should be compatible.

please also add unit tests for the new feature/methods.

cosmetic: code needs to be reformatted to 2 spaces indendation and file headers, but i can add that later as well.

@koenkicken
Copy link
Contributor Author

removed the @Override annotations to make it compatible

  • added unit tests for the new methods to testContentFragmentStructure()

@stefanseifert
Copy link
Member

thanks - i've done some cosmetic changes to reformat the code following our coding standards, and to reduce the visibility of the new classes as they are only interface implementations and should not be used directly.


@Override
public <T> @Nullable T getValue(Class<T> type) {
if (type.isInstance(value)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is too simplified. according to https://developer.adobe.com/experience-manager/reference-materials/cloud-service/javadoc/com/adobe/cq/dam/cfm/FragmentData.html#getValue(java.lang.Class) this should support any conversion. what about using OSGi converter e.g.

  public <T> @Nullable T getValue(Class<T> type) {
    return Converters.standardConverter().convert(value).defaultValue(null).targetAs(type);
  }

probably also update the unit tests a bit to test one or two actual conversions.


@Override
public boolean isTypeSupported(Class type) {
return type.isInstance(value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is too simplfied as well? following https://developer.adobe.com/experience-manager/reference-materials/cloud-service/javadoc/com/adobe/cq/dam/cfm/FragmentData.html#isTypeSupported(java.lang.Class) it should return true for any type supported to set as value (supported by the internal converters). it's not related to the value currently set. for sake of simplicity we could just return true here with a comment that this is simplified.

@henrykuijpers
Copy link
Contributor

@koenkicken We could use this as well, want to update this PR?

@koenkicken
Copy link
Contributor Author

@koenkicken We could use this as well, want to update this PR?

Don't have time for this at the moment, so go ahead :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

MockContentFragment_ContentElement_Structured does not support getValue()
3 participants