-
Notifications
You must be signed in to change notification settings - Fork 39
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
feat: FEEL function for invoking outbound connectors #2744
Closed
Closed
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
00f1ff6
feat(sdk): first iteration of document support
chillleader 1b5508d
apply review suggestions
chillleader 0c3a8bb
Merge branch 'documents-sdk' into epic-1748-doc-ref-handling
chillleader 50f2337
feat: connector feel function
chillleader f3d2a0e
hook up connector function dynamically
chillleader 4f4bf5c
clean up no args constructor from FeelDeserializer
chillleader a68ee5d
refactor secret resolution
chillleader 44ed2a6
implement transient document store
chillleader ed7c7a9
implement transient document store
chillleader File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...java/io/camunda/connector/runtime/core/external/ExternalOutboundConnectorContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. Camunda licenses this file to you under the Apache License, | ||
* Version 2.0; you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.camunda.connector.runtime.core.external; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.when; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import io.camunda.connector.api.json.ConnectorsObjectMapperSupplier; | ||
import io.camunda.connector.api.secret.SecretProvider; | ||
import io.camunda.connector.api.validation.ValidationProvider; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class ExternalOutboundConnectorContextTest { | ||
|
||
@Mock private SecretProvider secretProvider; | ||
private final ObjectMapper objectMapper = ConnectorsObjectMapperSupplier.DEFAULT_MAPPER; | ||
|
||
@Mock private ValidationProvider validationProvider; | ||
|
||
private record TestRecord(Integer key) {} | ||
|
||
private record NestedTestRecord(TestRecord nested) {} | ||
|
||
private record ArrayTestRecord(List<Integer> key) {} | ||
|
||
@Test | ||
void getVariablesAsTypeFromString() { | ||
var context = | ||
new ExternalOutboundConnectorContext( | ||
secretProvider, validationProvider, objectMapper, "{\"key\": 3}"); | ||
TestRecord result = context.bindVariables(TestRecord.class); | ||
assertThat(result.key()).isEqualTo(3); | ||
} | ||
|
||
@Test | ||
void getVariablesAsTypeFromObject() { | ||
var context = | ||
new ExternalOutboundConnectorContext( | ||
secretProvider, validationProvider, objectMapper, Map.of("key", 3)); | ||
TestRecord result = context.bindVariables(TestRecord.class); | ||
assertThat(result.key()).isEqualTo(3); | ||
} | ||
|
||
@Test | ||
void secretsAreReplaced() { | ||
var context = | ||
new ExternalOutboundConnectorContext( | ||
secretProvider, validationProvider, objectMapper, Map.of("key", "{{secrets.KEY}}")); | ||
when(secretProvider.getSecret("KEY")).thenReturn("5"); | ||
TestRecord result = context.bindVariables(TestRecord.class); | ||
assertThat(result.key()).isEqualTo(5); | ||
} | ||
|
||
@Test | ||
void nestedSecretsAreReplaced() { | ||
var context = | ||
new ExternalOutboundConnectorContext( | ||
secretProvider, | ||
validationProvider, | ||
objectMapper, | ||
Map.of("nested", Map.of("key", "{{secrets.KEY}}"))); | ||
when(secretProvider.getSecret("KEY")).thenReturn("5"); | ||
NestedTestRecord result = context.bindVariables(NestedTestRecord.class); | ||
assertThat(result.nested().key()).isEqualTo(5); | ||
} | ||
|
||
@Test | ||
void arraySecretsAreReplaced() { | ||
var context = | ||
new ExternalOutboundConnectorContext( | ||
secretProvider, | ||
validationProvider, | ||
objectMapper, | ||
Map.of("key", List.of("{{secrets.KEY}}"))); | ||
|
||
when(secretProvider.getSecret("KEY")).thenReturn("5"); | ||
ArrayTestRecord result = context.bindVariables(ArrayTestRecord.class); | ||
assertThat(result.key()).containsExactly(5); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename
jsonVariables
tovariables
?