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

NO ISSUE: Migrate assertions to assertj #6081

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.junit.jupiter.api.Test;
import org.kie.api.runtime.rule.FactHandle;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;

@QuarkusTest
public class RuntimeTest {
Expand Down Expand Up @@ -69,7 +69,7 @@ public void delete(DataHandle handle) {

instance.fire();

assertEquals("Hi 1", output.get().getText());
assertThat(output.get().getText()).isEqualTo("Hi 1");
}

@Test
Expand Down Expand Up @@ -101,6 +101,6 @@ public void delete(DataHandle handle) {

instance.fire();

assertEquals("Hi 2", output.get().getText());
assertThat(output.get().getText()).isEqualTo("Hi 2");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
import org.junit.jupiter.api.extension.RegisterExtension;

import static io.restassured.RestAssured.given;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;

public class HotReloadIT {

Expand All @@ -50,7 +49,7 @@ public class HotReloadIT {
public void testServletChange() throws InterruptedException {
String personsPayload = "[{\"name\":\"Mario\",\"age\":45,\"adult\":false},{\"name\":\"Sofia\",\"age\":17,\"adult\":false}]";

List names = given()
List<String> names = given()
.baseUri("http://localhost:" + HTTP_TEST_PORT)
.contentType(ContentType.JSON)
.accept(ContentType.JSON)
Expand All @@ -60,10 +59,9 @@ public void testServletChange() throws InterruptedException {
.then()
.statusCode(200)
.extract()
.as(List.class);
.<List<String>>as(List.class);

assertEquals(1, names.size());
assertEquals("Mario", names.get(0));
assertThat(names).hasSize(1).containsExactly("Mario");

test.modifyResourceFile(RESOURCE_FILE, s -> s.replaceAll("18", "16"));

Expand All @@ -75,10 +73,8 @@ public void testServletChange() throws InterruptedException {
.post("/find-adult")
.then()
.statusCode(200)
.extract().as(List.class);
.extract().<List<String>>as(List.class);

assertEquals(2, names.size());
assertTrue(names.contains("Mario"));
assertTrue(names.contains("Sofia"));
assertThat(names).hasSize(2).containsExactlyInAnyOrder("Mario", "Sofia");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
import org.kie.api.runtime.KieRuntimeBuilder;
import org.kie.api.runtime.KieSession;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.assertj.core.api.Assertions.assertThat;
import static org.kie.api.prototype.PrototypeBuilder.prototype;

@QuarkusTest
Expand All @@ -58,16 +57,15 @@ public void testYamlEvaluation() {

private void testSimpleDrl(KieSession ksession, String assetPackage) {
List<String> pkgNames = ksession.getKieBase().getKiePackages().stream().map(KiePackage::getName).collect(Collectors.toList());
assertEquals(2, pkgNames.size());
assertTrue(pkgNames.contains("org.drools.quarkus.test"));
assertTrue(pkgNames.contains(assetPackage));

assertThat(pkgNames).hasSize(2).containsExactlyInAnyOrder("org.drools.quarkus.test", assetPackage);

Result result = new Result();
ksession.insert(result);
ksession.insert(new Person("Mark", 17));
ksession.fireAllRules();

assertEquals("Mark can NOT drink", result.toString());
assertThat(result.toString()).isEqualTo("Mark can NOT drink");
}

@Test
Expand All @@ -85,7 +83,6 @@ public void testPrototypeEvaluation() {
ksession.insert(result);

ksession.fireAllRules();

assertEquals("Mark can NOT drink", result.get("value"));
assertThat(result.get("value")).isEqualTo("Mark can NOT drink");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import jakarta.inject.Inject;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;

@QuarkusTest
public class RuntimeTest {
Expand All @@ -42,7 +42,6 @@ public void testRuleUnit() {
instance.fire();
}

assertEquals(1, unit.getResults().size());
assertEquals("Hello Mario", unit.getResults().get(0));
assertThat(unit.getResults()).hasSize(1).containsExactly("Hello Mario");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
package org.drools.quarkus.util.deployment;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

import org.kie.api.builder.model.KieBaseModel;

Expand Down
Loading