Skip to content

Commit

Permalink
fix(tests): update BDRepositoryIT (#3265)
Browse files Browse the repository at this point in the history
---------
Co-authored-by: bonita-ci <[email protected]>
  • Loading branch information
rbioteau authored Nov 26, 2024
1 parent 07bce7b commit b563ee8
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ dependencies {
api project(':bpm:bonita-client')
api project(':bonita-integration-tests:bonita-test-utils')
api libs.assertj
api libs.jsonUnitFluent
api(libs.jsonUnit) {
exclude(group: "org.slf4j", module: "slf4j-api")
}
api libs.systemRules
api libs.concurrentUnit
runtimeOnly libs.logback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package org.bonitasoft.engine.business.data;

import static java.util.Collections.singletonList;
import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
import static org.apache.commons.lang3.StringUtils.substringAfter;
import static org.apache.commons.lang3.StringUtils.substringBefore;
import static org.assertj.core.api.Assertions.*;
Expand Down Expand Up @@ -1775,7 +1775,9 @@ private void verifyCommandGetBusinessDataByIds(final SimpleBusinessDataReference
// then
assertThatJson(lazyAddressResultWithChildName).as("should get address with lazy link to country")
.node("[0].addresses[0].links[0]")
.isEqualTo("{\"rel\":\"country\",\"href\":\"/businessdata/com.company.model.Address/2/country\"}");
.isObject()
.containsEntry("rel", "country")
.containsKey("href");
}

private void verifyCommandGetBusinessDataById(final SimpleBusinessDataReference businessDataReference)
Expand All @@ -1802,7 +1804,9 @@ private void verifyCommandGetBusinessDataById(final SimpleBusinessDataReference
// then
assertThatJson(employeeResultWithAddress).as("should get employee with lazy link to country in addresses")
.node("addresses[0].links[0]")
.isEqualTo("{\"rel\":\"country\",\"href\":\"/businessdata/com.company.model.Address/2/country\"}");
.isObject()
.containsEntry("rel", "country")
.containsKey("href");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
**/
package org.bonitasoft.engine.command;

import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
import static org.assertj.core.api.Assertions.assertThat;
import static org.bonitasoft.engine.bdm.builder.BusinessObjectBuilder.aBO;
import static org.bonitasoft.engine.bdm.builder.BusinessObjectModelBuilder.aBOM;
Expand Down Expand Up @@ -52,7 +52,11 @@
import org.bonitasoft.engine.io.IOUtils;
import org.bonitasoft.engine.operation.LeftOperandBuilder;
import org.bonitasoft.engine.operation.OperatorType;
import org.junit.*;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
* @author Romain Bioteau
Expand Down
4 changes: 3 additions & 1 deletion bpm/bonita-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ dependencies {
testImplementation libs.mockitoCore
testImplementation libs.logback
testImplementation libs.jmockit
testImplementation libs.jsonUnitFluent
testImplementation(libs.jsonUnit) {
exclude(group: "org.slf4j", module: "slf4j-api")
}

testFixturesApi("org.bonitasoft.engine:bonita-business-object-model") {
artifact { classifier = 'tests' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
**/
package org.bonitasoft.engine.bdm.serialization;

import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
import static org.assertj.core.api.Assertions.assertThat;

import java.io.StringWriter;
Expand Down
4 changes: 3 additions & 1 deletion bpm/bonita-web-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ dependencies {
annotationProcessor libs.lombok

testImplementation(project(":bpm:bonita-server"))
testImplementation libs.jsonUnit
testImplementation(libs.jsonUnit) {
exclude(group: "org.slf4j", module: "slf4j-api")
}
testImplementation libs.assertj
testImplementation libs.logback
testImplementation libs.springTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
**/
package org.bonitasoft.web.rest.server.api.bpm.flownode;

import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
Expand Down Expand Up @@ -192,7 +192,7 @@ private void checkJsonDataInstance(final DataInstanceImpl dataInstance, final St
.get();

//then
assertJsonEquals(getJson(jsonFile), response.getEntityAsText());
assertThatJson(getJson(jsonFile)).isEqualTo(response.getEntityAsText());
}

// Should be in bonita-common, engine side...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@
**/
package org.bonitasoft.web.rest.server.api.bpm.flownode;

import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;

import java.util.ArrayList;
Expand Down Expand Up @@ -128,7 +124,7 @@ public void should_TimerEventTrigger_return_number_as_strings() throws Exception
.get();

//then
assertJsonEquals(getJson("timerEventTriggerInstances.json"), response.getEntityAsText());
assertThatJson(getJson("timerEventTriggerInstances.json")).isEqualTo(response.getEntityAsText());
}

@Test
Expand All @@ -142,7 +138,7 @@ public void should_update_TimerEventTrigger_return_number_as_strings() throws Ex
.put("{\"executionDate\": 9223372036854775807}");

//then
assertJsonEquals(getJson("timerEventTriggerInstance.json"), response.getEntityAsText());
assertThatJson(getJson("timerEventTriggerInstance.json")).isEqualTo(response.getEntityAsText());
}

private SearchResult<TimerEventTriggerInstance> createSearchResult() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
**/
package org.bonitasoft.web.rest.server.api.system;

import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
import static org.bonitasoft.web.rest.server.utils.ResponseAssert.assertThat;
import static org.mockito.Mockito.when;

import java.util.HashMap;
import java.util.Map;

import net.javacrumbs.jsonunit.JsonAssert;
import net.javacrumbs.jsonunit.assertj.JsonAssertions;
import net.javacrumbs.jsonunit.core.Option;
import org.bonitasoft.console.common.server.i18n.I18n;
import org.bonitasoft.web.rest.server.utils.RestletTest;
Expand Down Expand Up @@ -60,13 +59,13 @@ public void should_return_translation_for_the_given_local() throws Exception {

assertThat(response).hasStatus(Status.SUCCESS_OK);

assertJsonEquals("[" +
JsonAssertions.assertThatJson("[" +
"{\"key\": \"key1\", \"value\": \"<strong>message 1</strong>\"}," +
"{\"key\": \"key2\", \"value\": \"autre méssage\"}," +
"{\"key\": \"key3\", \"value\": \"~%^*µ\"}" +
"]",
response.getEntityAsText(),
JsonAssert.when(Option.IGNORING_ARRAY_ORDER));
"]")
.when(Option.IGNORING_ARRAY_ORDER)
.isEqualTo(response.getEntityAsText());
}

@Test
Expand Down
3 changes: 1 addition & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ assertj = { group = "org.assertj", name = "assertj-core", version.ref = "assertj
xmlunit = { group = "xmlunit", name = "xmlunit", version.ref = "xmlunitVersion" }
mockitoCore = { group = "org.mockito", name = "mockito-core", version.ref = "mockitoVersion" }
mockitoJunitJupiter = { group = "org.mockito", name = "mockito-junit-jupiter", version.ref = "mockitoVersion" }
jsonUnit = { group = "net.javacrumbs.json-unit", name = "json-unit", version.ref = "jsonUnitVersion" }
jsonUnitFluent = { group = "net.javacrumbs.json-unit", name = "json-unit-fluent", version.ref = "jsonUnitVersion" }
jsonUnit = { group = "net.javacrumbs.json-unit", name = "json-unit-assertj", version.ref = "jsonUnitVersion" }
systemRules = { group = "com.github.stefanbirkner", name = "system-rules", version.ref = "systemRulesVersion" }
systemLambda = { group = "com.github.stefanbirkner", name = "system-lambda", version.ref = "systemLambdaVersion" }
concurrentUnit = { group = "net.jodah", name = "concurrentunit", version.ref = "concurrentUnitVersion" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies {
compileOnly libs.lombok

testImplementation libs.assertj
testImplementation libs.jsonUnitFluent
testImplementation libs.jsonUnit
testImplementation libs.mockitoCore
testImplementation libs.logback
testImplementation libs.narayanaJta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
**/
package org.bonitasoft.engine.business.data.impl;

import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
import static org.mockito.Mockito.mock;

import java.io.IOException;
Expand Down

0 comments on commit b563ee8

Please sign in to comment.