SAP / open-ux-odata

Enable community collaboration to jointly promote and facilitate best in class framework and tooling capabilities when working with OData services.
Apache License 2.0
51 stars 11 forks source link

BUG - MockServer: FunctionImport with EntitySet Attribute Not Detected by `execeuteAction` #771

Closed texttechne closed 8 months ago

texttechne commented 9 months ago

Description

Let's start with a compliment. The mock server is a wonderful piece of software, so thanks for your awesome work!

I'm successfully using the MockServer or more specifically the EntityContainerApi for mocking FunctionImports (file EntityContainer.js exporting method executeAction).

However, when the metadata specifies the EntitySet attribute the executeAction method is not called at all. Example:

<FunctionImport Name="FindSomething" ReturnType="NAMESPACE.SomethingEntity" EntitySet="SomethingEntitities" m:HttpMethod="GET"></FunctionImport>

Am I missing something here? Do I need to mock the function somewhere else? Then again, I don't understand why...

Expected results

Mock function executeAction gets called regardless whether the attribute EntitySet is set or not.

Actual results

I don't know how to mock such functions.

Version/Components/Environment

Add any other context about the problem here OS: Windows OData version: V2

Root Cause Analysis

Problem

{describe the problem}

Fix

{describe the fix}

Why was it missed

{Some explanation why this issue might have been missed during normal development/testing cycle}

How can we avoid this

{if we don’t want to see this type of issues anymore what we should do to prevent}

nlunets commented 9 months ago

If this is a bound action you need to create an executeAction method on the dedicated entityset file. So in your case you need a SomethingEntitities.js with executeAction inside

texttechne commented 9 months ago

Hi @nlunets, indeed it works the way you describe. Thanks!

However, this is quite surprising: It is a V2 service, so it's not a bound action but an unbound function (V2 only knows unbound functions via FunctionImport).

The EntitySet attribute I'm talking about is added when the ReturnType is a proper EntityType. When returning primitive types or complex types, then this attribute is not set.

This means, that the mock server differentiates between bound & unbound operations for V2 based on the return type, while in reality there exist no unbound operations for V2.

nlunets commented 9 months ago

That's true indeed... Changing this however would be a breaking change on the mockserver implementation that i'd like to avoid :)

The fact that you are on the correct entityset used for the return type seems also to be a good thing for me somehow.

texttechne commented 9 months ago

Changing this however would be a breaking change on the mockserver implementation that i'd like to avoid :)

Yeah, agreed.

But I would strongly recommend to update the documentation in this regard as it is unexpected behaviour.

nlunets commented 8 months ago

Documentation is now updated !