Skip to content

Commit e4dc730

Browse files
committed
feat: create ignore key at arangodb
Signed-off-by: Otavio Santana <[email protected]>
1 parent 5678f26 commit e4dc730

File tree

2 files changed

+64
-6
lines changed

2 files changed

+64
-6
lines changed

jnosql-arangodb/src/main/java/org/eclipse/jnosql/databases/arangodb/communication/ArangoDBUtil.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ static DocumentEntity toEntity(BaseDocument document) {
9696
static BaseDocument getBaseDocument(DocumentEntity entity) {
9797
Map<String, Object> map = new HashMap<>();
9898
for (Document document : entity.documents()) {
99+
if(KEY.equals(document.name()) && Objects.isNull(document.get())) {
100+
continue;
101+
}
99102
map.put(document.name(), convert(document.value()));
100103
}
101104
return new BaseDocument(map);

jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/integration/TemplateIntegrationTest.java

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void shouldDelete() {
116116
void shouldUpdateEmbeddable() {
117117
var workflowStep = WorkflowStep.builder()
118118
.id("id")
119-
.key("key")
119+
.key("key1")
120120
.workflowSchemaKey("workflowSchemaKey")
121121
.stepName("stepName")
122122
.mainStepType(MainStepType.MAIN)
@@ -130,8 +130,8 @@ void shouldUpdateEmbeddable() {
130130

131131
SoftAssertions.assertSoftly(soft ->{
132132
soft.assertThat(result).isNotNull();
133-
soft.assertThat(result.id()).isEqualTo("workflow_step/key");
134-
soft.assertThat(result.key()).isEqualTo("key");
133+
soft.assertThat(result.id()).isEqualTo("workflow_step/key1");
134+
soft.assertThat(result.key()).isEqualTo("key1");
135135
soft.assertThat(result.workflowSchemaKey()).isEqualTo("workflowSchemaKey");
136136
soft.assertThat(result.stepName()).isEqualTo("stepName");
137137
soft.assertThat(result.mainStepType()).isEqualTo(MainStepType.MAIN);
@@ -151,7 +151,7 @@ void shouldUpdateEmbeddable() {
151151
void shouldUpdateEmbeddable2() {
152152
var workflowStep = WorkflowStep.builder()
153153
.id("id")
154-
.key("key")
154+
.key("key2")
155155
.workflowSchemaKey("workflowSchemaKey")
156156
.stepName("stepName")
157157
.mainStepType(MainStepType.MAIN)
@@ -164,8 +164,63 @@ void shouldUpdateEmbeddable2() {
164164

165165
SoftAssertions.assertSoftly(soft ->{
166166
soft.assertThat(result).isNotNull();
167-
soft.assertThat(result.id()).isEqualTo("workflow_step/key");
168-
soft.assertThat(result.key()).isEqualTo("key");
167+
soft.assertThat(result.id()).isEqualTo("workflow_step/key2");
168+
soft.assertThat(result.key()).isEqualTo("key2");
169+
soft.assertThat(result.workflowSchemaKey()).isEqualTo("workflowSchemaKey");
170+
soft.assertThat(result.stepName()).isEqualTo("stepName");
171+
soft.assertThat(result.mainStepType()).isEqualTo(MainStepType.MAIN);
172+
soft.assertThat(result.stepNo()).isNull();
173+
soft.assertThat(result.componentConfigurationKey()).isEqualTo("componentConfigurationKey");
174+
soft.assertThat(result.relationTypeKey()).isEqualTo("relationTypeKey");
175+
soft.assertThat(result.availableTransitions()).isNull();
176+
});
177+
}
178+
179+
@Test
180+
void shouldExecuteWithoutKey(){
181+
var workflowStep = WorkflowStep.builder()
182+
.id("id")
183+
.workflowSchemaKey("workflowSchemaKey")
184+
.stepName("stepName")
185+
.mainStepType(MainStepType.MAIN)
186+
.stepNo(null)
187+
.componentConfigurationKey("componentConfigurationKey")
188+
.relationTypeKey("relationTypeKey")
189+
.availableTransitions(null)
190+
.build();
191+
var result = this.template.insert(workflowStep);
192+
193+
SoftAssertions.assertSoftly(soft ->{
194+
soft.assertThat(result).isNotNull();
195+
soft.assertThat(result.id()).contains("workflow_step/");
196+
soft.assertThat(result.key()).isNotNull();
197+
soft.assertThat(result.workflowSchemaKey()).isEqualTo("workflowSchemaKey");
198+
soft.assertThat(result.stepName()).isEqualTo("stepName");
199+
soft.assertThat(result.mainStepType()).isEqualTo(MainStepType.MAIN);
200+
soft.assertThat(result.stepNo()).isNull();
201+
soft.assertThat(result.componentConfigurationKey()).isEqualTo("componentConfigurationKey");
202+
soft.assertThat(result.relationTypeKey()).isEqualTo("relationTypeKey");
203+
soft.assertThat(result.availableTransitions()).isNull();
204+
});
205+
}
206+
207+
@Test
208+
void shouldExecuteWithoutKId(){
209+
var workflowStep = WorkflowStep.builder()
210+
.workflowSchemaKey("workflowSchemaKey")
211+
.stepName("stepName")
212+
.mainStepType(MainStepType.MAIN)
213+
.stepNo(null)
214+
.componentConfigurationKey("componentConfigurationKey")
215+
.relationTypeKey("relationTypeKey")
216+
.availableTransitions(null)
217+
.build();
218+
var result = this.template.insert(workflowStep);
219+
220+
SoftAssertions.assertSoftly(soft ->{
221+
soft.assertThat(result).isNotNull();
222+
soft.assertThat(result.id()).contains("workflow_step/");
223+
soft.assertThat(result.key()).isNotNull();
169224
soft.assertThat(result.workflowSchemaKey()).isEqualTo("workflowSchemaKey");
170225
soft.assertThat(result.stepName()).isEqualTo("stepName");
171226
soft.assertThat(result.mainStepType()).isEqualTo(MainStepType.MAIN);

0 commit comments

Comments
 (0)