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

FEATURE - Mock Stream properties #760

Open
3 tasks
junwei-tj opened this issue Dec 18, 2023 · 10 comments
Open
3 tasks

FEATURE - Mock Stream properties #760

junwei-tj opened this issue Dec 18, 2023 · 10 comments

Comments

@junwei-tj
Copy link

junwei-tj commented Dec 18, 2023

As a UI5 developer
I want to mock Stream properties of my dataset,
so that I can test my UI5 app is able to process them correctly

Description

What is the high level purpose and value of the feature? The description should ensure that anyone reading understands what it is doing (at a high level) and most importantly why.

Suppose we have the following metadata definition:

<EntityType Name="InspectionResults">
    ...
    <Property Name="image" Type="Edm.Stream" />`
    ...
</EntityType>
...
<Annotations Target="InspectionResults.InspectionResults/image">
                <Annotation Term="Core.Computed" Bool="false" />
                <Annotation Term="Core.MediaType" Path="mediaType" />
                <Annotation Term="Core.AcceptableMediaTypes">
                    <Collection>
                        <String>image/png</String>
                        <String>image/jpeg</String>
                    </Collection>
                </Annotation>
            </Annotations>

When we get the InspectionResults/image attribute, the image's binary data would be returned as response. Then, the frontend can display the image straightaway.

Sample response:
image
image

Sample query: curl --location 'localhost:8080/odata/v4/VisualInspectionResult.svc/InspectionResults(46cc8aa3-5e6e-447d-b571-b01e4612cbcf)/image'

Technical Design

What modules need to be created or enhanced?
How would the functionality be exposed and how can it be consumed?

Acceptance Criteria

GivenWhenThen format (https://martinfowler.com/bliki/GivenWhenThen.html)

Given I have a ...
when I execute ...
then ... will happen.

Notes

Tasks

  • Unit Tests added
  • Test Cases defined
@nlunets
Copy link
Member

nlunets commented Dec 18, 2023

How is this large binary requested / retrieved in your official server ? Do you have sample output ?

@junwei-tj
Copy link
Author

The images are downloaded from S3, then converted into an InputStream (in Java) before it is sent out with the other response data.

Not sure how to show a sample output, but when we make a request to e.g. /odata/v4/OurService/OurEntity(1234)/image, on e.g. postman or browser, it displays the image straightaway.

@nlunets
Copy link
Member

nlunets commented Dec 18, 2023

Do you have a sample response from an HTTP standpoint ?

@junwei-tj
Copy link
Author

Not sure if this will help:
image
image

@nlunets
Copy link
Member

nlunets commented Dec 18, 2023

The raw response would help, as well as the associated query, because otherwise it just looks like you are getting an image :)

@junwei-tj
Copy link
Author

junwei-tj commented Dec 18, 2023

This is a sample query: curl --location 'localhost:8080/odata/v4/VisualInspectionResult.svc/InspectionResults(46cc8aa3-5e6e-447d-b571-b01e4612cbcf)/image' --output 'Documents/http.txt'

This is the literal raw response from curl, seems to be a binary output:

ˇÿˇ‡��JFIF����������ˇ€�C�����������		�
�
��������������� $.' ",#��(7),01444�'9=82<.342ˇ€�C�			��

�2!�!22222222222222222222222222222222222222222222222222ˇ¿����[�`��"�������ˇƒ����������������������������	
�ˇƒ�µ����������������}��������!1A��Qa�"q�2Åë°�#B±¡�R—$3brÇ	
�����%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzÉÑÖÜáàâäíìîïñóòôö¢£§•¶ß®©™≤≥¥µ∂∑∏π∫¬√ƒ≈∆«»… “”‘’÷◊ÿŸ⁄·‚„‰ÂÊÁËÈÍÒÚÛÙıˆ˜¯˘˙ˇƒ����������������������������	
�ˇƒ�µ����������������w�������!1��AQ�aq�"2Å��Bë°±¡	#3R�br—
�$4·%Ò����&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzÇÉÑÖÜáàâäíìîïñóòôö¢£§•¶ß®©™≤≥¥µ∂∑∏π∫¬√ƒ≈∆«»… “”‘’÷◊ÿŸ⁄‚„‰ÂÊÁËÈÍÚÛÙıˆ˜¯˘˙ˇ⁄���������?�ÙÔ�¯öm:˚Ï÷7®íF�û3�([�NHÁ9ÌËjæü‚ÌA̸ÿ¥ΩWTVlG:[¨q:˙ÉåÁ ˙è~EQ¯ô¶$R[j©�	)�›�¥��ÜRx‹«�î}Etæ
ºäÁ√pA�*�Bmÿ*Ì���=¡�ûß5
¸ÃΩ,A'â5/, ˙\÷ã�Ã͈≥NŒ=�U�}I5�øƒ
6eI%	o�p˛t°_'¶‘Ífi˝1Ô]uG=º71�Æ!éXœTëC�¯�´>‰›v+A™[‹�Ufi�»ÿ•rYOG¿Œ�˙ú{‚≠«"J•£uuTï9���}A�~�ã?ÑtYLØ
©≥íUÿÔg#@HÙ!H�Ò��ö.Øk2Õe™�†�~ÓÒ��,�ò÷E�(%F~\ú�û95
�éä°Ò5∆òL~!∑í‘�spS˜d‡±√�6é��w�8Œk£∂ªÇÓ2ˆÚ¨Ä�≠É ë‘�ÿ˚Pò¨ME�S�¢ä(�'ƒ∫gˆ∑áÓÌT~˜f¯àPHu‰c=¯«„^�˚S˚�µˆ6�\�*#9¿
„Ód‰ˆ;�:úı5Í’„^#≥ì√fi(πx�ƒ®ˇ�jÅñ���;Ü;��ίˆÎQ-� ècŸh™∫mÚjzeµÏx�<j˚Cn⁄H‰g‘�è¬≠Uí�QE�5—dFGP»√�Xd�\›ÔÑQKœ°›>ôrQî*s�!«›˛�d$c凇◊ME��ù¥Ò�÷˜´a≠€�[â�dR�ö9I|�≠flÜAú�NÓ��Ω—‹A�Ò6ˉPÍpFA��i.≠`Ωµí⁄Ê$ñ	Wk£åÇ+ŒµMV˜¬û"∏ãLéKç>�PŒ≤∞˝¿‹∏�ŒY�x�BGÆ�*[∞˜=*ä«–|GeØAò�$Í2ñ…�‘�„ß>„÷∂*ì∏Ç∏�à˙cˇ�fÆ∑kng∫µ¬≤á#˜yŒ@ı
¥˝3]≈2hc∏ÇH%]—»•�såÇ0E&ÆÜéO¡üo∑Õ∞∂é�´W,1∏+∂3˜G‹‰ı≠IuçF�q6üg���f†�w˛;\^â�√
÷ç0�ã�Ÿ-ã2„z�
®��(»��ˇ�öͱ≈k©Ω§>�∑∏*	�õ���NKèqÍpj�û≈4u«ƒ�@Û�ôè_Ì.ü˘�£óƒÚƒÅæœe.N6√vƒ˛±Å˙◊õ>Øl'���E∏ÇGÓôÅ�‡Ú$«R?:Æ<G£ÉÉ·ã2{Äø˝≤ùŸ'≠Z¯ÇKúm“o	?‹(@˙í¬Æ
Br˚�≤Øsıã�ß}˛ˇ�Á�‰pxÉ√rÄ∑��‹I‡ƒ≈�¸ò◊Af4œ%.m,.t¯2�ÿbbß=r»œ‘˙ˇ�*9ö��flˆõÇ�i◊Kûõö!ü¸~π��G®Æµk≠XX›¥∂Ç–®���⁄I\ÜS—ÜA«Cœ�-®}奩s;î�;IsΩ@Îí0�˝*�ˇ��‹XK���àu¡rH$Á¶��÷ßû˚é«ûI©y�\fl�˚�UyvôA��;Nr9œ�‡d„�Ωg¡fi!Ƀæ�∑æÜI]‘�gicÿ∆E�q¿„� åqœnÉÕµ≠QuâÂyl‚äR:Øu9»9ÎœØÚÆÀ·ã¨û�ªd�}∫E˙·T�JpzÉÿÌh¢ä–ìÅ÷⁄M?≈”ŒÍ•eŸ$y�ÙPπˆÂMix~�Ø5kŸÓ÷9ZDI �ÇB‰´`{��8˛uC∆∑�-Qb1¬∆Kx»w\∫·fl;OlÁü¬≥ÙãŸíE�ÄΩÃ,fä5Î(�˜â–˝Â�}Tc≠g¥ãËt>'“§X^Í fiŸ≤ÑHín�R� �ÅŒG�s^uq·ùV�û8· D„,G�CqúcÈ“Ω[Q’4À≠�yñÚ›„hã g�3�ê§�q ü°Æ�%¥πÖ≠Ê2À�@Ré72ûÉÄrŸ«Ú«J%£�9kKkª©%Ka��6�ìÓ
«�ì¿>˛ôÌöÌ</•‹jP\B.b墫Êó∑Y�Ûû�pTçß'>ú�9ÃO	jí]ï≤ÇH aò›‰˘‘�†Äx8Î∏��9<�H–ÙøÏù5`gfl;±íg…;úı<˝�œ|dÚM	]ãcû汪≥∏û⁄fi‚%)nnYˆr 8<sŒ�»ÆgUπö„M≥öF˝„K*6“v¸°:�›OÈíp+§ÒSŸ�h}≠<ÿñ‹�El�Ÿb�{�üÖ`ù*ÛR—
ÕØí-Ï⁄gê3�üïN�‡;˚T5≠ëHÁ|“Íë∞‰)b
ÛìÅå˜�tœØ©ÆÔ·H«Üo≥◊˚J�È\�o2BW�ÿC)·Å�ˇ�ü˛Ωz�¬ÙŸ·´±Î�)˝�™�ÉÿÌ®¢ä‘Éœ|�±5�ëõn€aŒ3èôªW�ó3˝≠�&‡\Ó_-#Ϊ=znŒqåWq‚YF°‚âlcReä�ó�fi…-«Á\f≥ß|ˇ�hAŒ:˙èßߢÔY=Õ-°πum%ıò÷-Ï£yÿfı^2^'�ÅpßçßìúpW® ’Ì�fi‰Îvˆ˜∂€�˚úJf“畘Æ:��)Œ�ãøN�”Zº”n�‚›ôgRCJ��Á˚Ζé�Ó�zb∂tø�••ÍfiK°√,ÈÚâ!�	'�I#ïÁ=Ä�“%ûÿ™�B®��Ä�jºY‚‰—PŸŸÅ.†‡{¨ Ù-ÔË?�€<.ßÒfÚÓŸ‚∑˚-îrå	VMŒ=p›�¶q˙’c™€C��hó-�$ˆÍ˜ÇUWO7´.Xaπ«ÛÕSzh$ÑöÍÌÓÕ≈’ÃìÀ9À�«�Å¿�Ä5ÏZRA�ìh∂flÍ|•*H�ú剄πÍ}΃ou≈ªLœ�åÆÿ≠v�¯"ÛıÁ⁄µÏ˛!Í:Fço
≠öK�wEíx^>òcíH�«S�a¥U÷÷ÿx¶ÌÏó�|Í�∆“πÌé1íqÏEwfl�SgáÆ�≠€üÕT◊ëE©õã©&ítíYÚôfiX‰Ûû˘=	˙ì^…‡8Z/�3ëƒ≥≥/–�ø˚)•�àoc®¢ä+R��Òùˆ§<kttÎ�´µ�Bµ≤n Ä�ɯäzÍfi%ôr˛�ΩûC˜§û‹Ç«fl��~∏˙ÊΩéäûRπèûµ=#ƒ⁄çÀœ'Ö55êíGï
(LÒÖ¡‡U+o�xŒv+�ìy�Î˛í¯˝H5Ùï�Ï+ü<߬ˇ��nfil„œ˝Ñ�´∞¸2Ò° õ{4�Ì_�ü…+fih¢¡s¬£¯9‚K√õ◊—¢PN2“ª~ò˛um>�ÍQ±ÚÊ—�‡f[y�<så±Øj¢ã�œ)±¯Y©Yß��Zær|à⁄5?QÉöÙ?�i≥i��µåÚ,í≈ªs©‡ÂâÙ�æïßE	$
‹ˇŸ

Sorry if this doesn't help, I don't know what other response fields I can show you because I am literally just getting the image itself as the response.

If you're asking how the response would look like as the entire entity JSON object, the way our service is implemented, on a normal GET request (so just localhost:8080/odata/v4/VisualInspectionResult.svc/InspectionResults(46cc8aa3-5e6e-447d-b571-b01e4612cbcf)), the image field would be null. Only when we explicitly request for it by appending /image to the URL would the above image response be sent.

@nlunets
Copy link
Member

nlunets commented Dec 18, 2023

Hmmm, can you share the metadata definition around this InspectionResults EntitySet ?
I assume that this migth be a stream property but i'm not 100% sure

@junwei-tj
Copy link
Author

Yup, it's a stream:

<EntityType Name="InspectionResults">
    ...
    <Property Name="image" Type="Edm.Stream" />`
    ...
</EntityType>
...
<Annotations Target="InspectionResults.InspectionResults/image">
                <Annotation Term="Core.Computed" Bool="false" />
                <Annotation Term="Core.MediaType" Path="mediaType" />
                <Annotation Term="Core.AcceptableMediaTypes">
                    <Collection>
                        <String>image/png</String>
                        <String>image/jpeg</String>
                    </Collection>
                </Annotation>
            </Annotations>

@nlunets
Copy link
Member

nlunets commented Dec 18, 2023

Then we don't support Stream properties currently, you'd need an enhancement request for this :)

@junwei-tj
Copy link
Author

Got it, thanks for the help! Have updated this issue accordingly :)

@junwei-tj junwei-tj changed the title FEATURE - Mock LargeBinary type FEATURE - Mock Stream properties Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants