Skip to content

Commit

Permalink
[plugins/backend-application-default] improves sonnar reports
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangsa committed Aug 31, 2024
1 parent 6da69ab commit 70eb6ab
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import static com.tngtech.archunit.library.Architectures.layeredArchitecture;
import static com.tngtech.archunit.library.Architectures.onionArchitecture;

@AnalyzeClasses(packages = "{{basePackage}}", importOptions = DoNotIncludeTests.class)
public class ArchitectureTest {
class ArchitectureTest {

/**
* Validates that dependencies between layers respect hexagonal/onion/clean architecture.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import static org.mockito.Mockito.*;
/**
* Acceptance Test for {{service.name}}.
*/
public class {{service.name}}Test {
class {{service.name}}Test {

private final Logger log = LoggerFactory.getLogger(getClass());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import static org.mockito.Mockito.*;
/**
* Acceptance Test for {{service.name}}.
*/
public class {{service.name}}Test {
class {{service.name}}Test {

private final Logger log = LoggerFactory.getLogger(getClass());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;

import jakarta.persistence.EntityManager;

public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositoryIntegrationTest {
class {{entity.className}}RepositoryIntegrationTest extends BaseRepositoryIntegrationTest {

@Autowired
EntityManager entityManager;
Expand All @@ -22,26 +22,26 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor
{{entity.className}}Repository {{entity.instanceName}}Repository;

@Test
public void findAllTest() {
void findAllTest() {
var results = {{entity.instanceName}}Repository.findAll();
Assertions.assertFalse(results.isEmpty());
}


@Test
public void findByIdTest() {
void findByIdTest() {
var id = 1L;
var {{entity.instanceName}} = {{entity.instanceName}}Repository.findById(id).orElseThrow();
Assertions.assertTrue({{entity.instanceName}}.getId() != null);
Assertions.assertTrue({{entity.instanceName}}.getVersion() != null);
Assertions.assertNotNull({{entity.instanceName}}.getId());
Assertions.assertNotNull({{entity.instanceName}}.getVersion());
{{~#if (or entity.options.auditing entity.options.extendsAuditing)}}
Assertions.assertTrue({{entity.instanceName}}.getCreatedBy() != null);
Assertions.assertTrue({{entity.instanceName}}.getCreatedDate() != null);
Assertions.assertNotNull({{entity.instanceName}}.getCreatedBy());
Assertions.assertNotNull({{entity.instanceName}}.getCreatedDate());
{{~/if}}
}

@Test
public void saveTest() {
void saveTest() {
{{entity.className}} {{entity.instanceName}} = new {{entity.className}}();
{{~#each entity.fields as |field|}}
{{entity.instanceName}}.set{{capitalize field.name}}({{{populateField field}}});
Expand Down Expand Up @@ -79,18 +79,18 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor
// reloading to get relationships persisted by id
entityManager.flush();
entityManager.refresh(created);
Assertions.assertTrue(created.getId() != null);
Assertions.assertTrue(created.getVersion() != null);
Assertions.assertNotNull(created.getId());
Assertions.assertNotNull(created.getVersion());
{{~#if (or entity.options.auditing entity.options.extendsAuditing)}}
Assertions.assertTrue(created.getCreatedBy() != null);
Assertions.assertTrue(created.getCreatedDate() != null);
Assertions.assertNotNull(created.getCreatedBy());
Assertions.assertNotNull(created.getCreatedDate());
{{~/if}}

{{#each entity.relationships as |relationship|}}
{{~#if relationship.fieldName}}
{{~#if relationship.ownerSide}}
{{~#if (endsWith relationship.type 'OneToOne')}}
Assertions.assertTrue({{entity.instanceName}}.get{{capitalize relationship.fieldName}}().getId() != null);
Assertions.assertNotNull({{entity.instanceName}}.get{{capitalize relationship.fieldName}}().getId() != null);
{{~else if (endsWith relationship.type 'ToOne')}}
Assertions.assertTrue({{entity.instanceName}}.get{{capitalize relationship.fieldName}}().getId() == {{relationship.fieldName}}Id);
{{~else}}
Expand All @@ -102,7 +102,7 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor
}

@Test
public void updateTest() {
void updateTest() {
var id = 1L;
var {{entity.instanceName}} = {{entity.instanceName}}Repository.findById(id).orElseThrow();
{{~#each entity.fields as |field|}}
Expand All @@ -116,7 +116,7 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor
}

@Test
public void deleteTest() {
void deleteTest() {
var id = 1L;
{{entity.instanceName}}Repository.deleteById(id);
var notFound = {{entity.instanceName}}Repository.findById(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositoryIntegrationTest {
class {{entity.className}}RepositoryIntegrationTest extends BaseRepositoryIntegrationTest {

@Autowired
{{entity.className}}Repository {{entity.instanceName}}Repository;

@Test
public void findAllTest() {
void findAllTest() {
var results = {{entity.instanceName}}Repository.findAll();
Assertions.assertFalse(results.isEmpty());
}


@Test
public void findByIdTest() {
void findByIdTest() {
var id = "1";
var {{entity.instanceName}} = {{entity.instanceName}}Repository.findById(id).orElseThrow();
Assertions.assertTrue({{entity.instanceName}}.getId() != null);
Expand All @@ -30,7 +30,7 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor
}

@Test
public void saveTest() {
void saveTest() {
{{entity.className}} {{entity.instanceName}} = new {{entity.className}}();
{{~#each entity.fields as |field|}}
{{entity.instanceName}}.set{{capitalize field.name}}(null);
Expand All @@ -45,7 +45,7 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor
}

@Test
public void updateTest() {
void updateTest() {
var id = "1";
var {{entity.instanceName}} = {{entity.instanceName}}Repository.findById(id).orElseThrow();
{{~#each entity.fields as |field|}}
Expand All @@ -59,7 +59,7 @@ public class {{entity.className}}RepositoryIntegrationTest extends BaseRepositor
}

@Test
public void deleteTest() {
void deleteTest() {
var id = "1";
{{entity.instanceName}}Repository.deleteById(id);
var notFound = {{entity.instanceName}}Repository.findById(id);
Expand Down

0 comments on commit 70eb6ab

Please sign in to comment.