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

Fix main tests due to tests not cleaning data created by itself #149

Merged
merged 11 commits into from
Nov 2, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;


@QuarkusTest
@QuarkusTestResource(value = PostgreSQLDatabaseTestResource.class,
initArgs = {
Expand All @@ -44,7 +43,11 @@ public class ApplicationImportNullTest extends SecuredResourceTest {
@Test
@Transactional
public void testNullApplicationName() {
// Assert previous state
long initialNumberOfImportSummaries = ImportSummary.count();
long initialNumberOfApplicationImport = ApplicationImport.count();

// Execute tests
ImportSummary importSummary = new ImportSummary();
importSummary.persistAndFlush();

Expand Down Expand Up @@ -93,7 +96,7 @@ public void testNullApplicationName() {
.get("/application-import")
.as(ApplicationImport[].class);


// Clean data
Arrays.asList(importList).forEach(thisImport ->
given()
.accept(ContentType.JSON)
Expand All @@ -103,12 +106,19 @@ public void testNullApplicationName() {
.then()
.statusCode(204));


importSummary.delete();
assertEquals(initialNumberOfImportSummaries, ImportSummary.count());
assertEquals(initialNumberOfApplicationImport, ApplicationImport.count());
}

@Test
@Transactional
protected void testNullTagTypes() {
// Assert previous state
long initialNumberOfImportSummaries = ImportSummary.count();
long initialNumberOfApplicationImport = ApplicationImport.count();

// Execute tests
ImportSummary appImportParent = new ImportSummary();
appImportParent.persistAndFlush();

Expand Down Expand Up @@ -228,11 +238,22 @@ protected void testNullTagTypes() {
assertNull(appImport1.getTagType19());
assertNull(appImport1.getTag20());
assertNull(appImport1.getTagType20());

// Clean data
appImportParent.delete();

assertEquals(initialNumberOfImportSummaries, ImportSummary.count());
assertEquals(initialNumberOfApplicationImport, ApplicationImport.count());
}

@Test
@Transactional
protected void testNullDependency() {
// Assert previous state
long initialNumberOfImportSummaries = ImportSummary.count();
long initialNumberOfApplicationImport = ApplicationImport.count();

// Execute tests
ImportSummary appImportParent = new ImportSummary();
appImportParent.persistAndFlush();

Expand Down Expand Up @@ -277,6 +298,14 @@ protected void testNullDependency() {
apiMapper.map(appImport3, appImportParent3.id);

assertNull(appImport3.getDependencyDirection());

// Clean data
appImportParent.delete();
appImportParent2.delete();
appImportParent3.delete();

assertEquals(initialNumberOfImportSummaries, ImportSummary.count());
assertEquals(initialNumberOfApplicationImport, ApplicationImport.count());
}

}