Skip to content

Commit

Permalink
PR Amendments
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilDigitalJustice committed Apr 3, 2024
1 parent fec6ea2 commit 78e48e3
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 28 deletions.
34 changes: 17 additions & 17 deletions assessment-api/open-api-specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ paths:
summary: 'get assessments'
operationId: 'getAssessments'
parameters:
- $ref: '#/components/parameters/assessmentParameter'
- $ref: '#/components/parameters/assessmentType'
- name: 'provider-id'
in: 'query'
schema:
Expand Down Expand Up @@ -73,7 +73,7 @@ paths:

components:
parameters:
assessmentParameter:
assessmentType:
name: name
in: query
schema:
Expand Down Expand Up @@ -131,6 +131,21 @@ components:
format: 'date'
last_saved_by:
type: 'string'
assessmentEntityTypeDetail:
type: object
properties:
id:
type: string
name:
type: string
entities:
type: array
items:
$ref: '#/components/schemas/assessmentEntityDetail'
required:
- id
- entityType
- entities
assessmentEntityDetail:
type: object
properties:
Expand All @@ -154,21 +169,6 @@ components:
- id
- entityId
- prepopulated
assessmentEntityTypeDetail:
type: object
properties:
id:
type: string
name:
type: string
entities:
type: array
items:
$ref: '#/components/schemas/assessmentEntityDetail'
required:
- id
- entityType
- entities
assessmentAttributeDetail:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package uk.gov.laa.ccms.caab.assessment.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
Expand All @@ -10,6 +11,7 @@
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.type.NumericBooleanConverter;

/**
* Represents an attribute of an Oracle Intelligence Advisor entity.
Expand Down Expand Up @@ -74,13 +76,15 @@ public class OpaAttribute {
* Indicates if the attribute is prepopulated.
*/
@Column(name = "PREPOPULATED", nullable = false)
private boolean prepopulated;
@Convert(converter = NumericBooleanConverter.class)
private Boolean prepopulated;

/**
* Indicates if the attribute was asked in the session.
*/
@Column(name = "ASKED")
private boolean asked = false;
@Convert(converter = NumericBooleanConverter.class)
private Boolean asked;


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
Expand All @@ -13,6 +14,7 @@
import jakarta.persistence.Table;
import java.util.List;
import lombok.Data;
import org.hibernate.type.NumericBooleanConverter;

/**
* Represents an Oracle Intelligence Advisor entity.
Expand Down Expand Up @@ -60,7 +62,7 @@ public class OpaEntity {
private String entityId;

/**
* The type of the entity.
* The attributes of the entity.
*/
@OneToMany(
mappedBy = "opaEntity",
Expand All @@ -83,7 +85,8 @@ public class OpaEntity {
* Indicates if the entity is prepopulated.
*/
@Column(name = "PREPOPULATED")
private boolean prepopulated;
@Convert(converter = NumericBooleanConverter.class)
private Boolean prepopulated;


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
Expand All @@ -14,6 +15,7 @@
import jakarta.persistence.Table;
import java.util.Set;
import lombok.Data;
import org.hibernate.type.NumericBooleanConverter;

/**
* Represents an Oracle Intelligence Advisor relationship.
Expand Down Expand Up @@ -69,5 +71,6 @@ public class OpaRelationship {
* Indicates if the relationship is prepopulated.
*/
@Column(name = "PREPOPULATED")
private boolean prepopulated;
@Convert(converter = NumericBooleanConverter.class)
private Boolean prepopulated;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
/**
* Mapper for mapping between assessment entities and models.
*/
@Mapper(componentModel = "spring")
@Mapper(componentModel = "spring",
uses = CommonMapper.class)
public interface AssessmentMapper {

@Mapping(target = "assessment", source = "name")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package uk.gov.laa.ccms.caab.assessment.mapper;

import org.mapstruct.Mapper;

/**
* Common mappings which can be used by other mappers.
*/
@Mapper(componentModel = "spring")
public interface CommonMapper {

/**
* Global mapper to default Booleans to FALSE in the case of a null source value.
*
* @param flag - the source value
* @return the source value, or FALSE.
*/
default Boolean toBoolean(Boolean flag) {
return flag != null ? flag : Boolean.FALSE;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
import java.util.Set;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import uk.gov.laa.ccms.caab.assessment.entity.OpaAttribute;
import uk.gov.laa.ccms.caab.assessment.entity.OpaEntity;
import uk.gov.laa.ccms.caab.assessment.entity.OpaListEntity;
Expand All @@ -27,14 +32,14 @@
import uk.gov.laa.ccms.caab.assessment.model.AssessmentRelationshipTargetDetail;
import uk.gov.laa.ccms.caab.assessment.model.AuditDetail;

@ExtendWith(MockitoExtension.class)
class AssessmentMapperTest {

private AssessmentMapperImpl assessmentMapper;
@InjectMocks
private AssessmentMapperImpl assessmentMapper = new AssessmentMapperImpl();

@BeforeEach
void setUp() {
assessmentMapper = new AssessmentMapperImpl();
}
@Mock(answer = Answers.CALLS_REAL_METHODS)
private CommonMapper commonMapper;

@Test
void testToAssessmentDetailsWithNonNullSessions() {
Expand Down

0 comments on commit 78e48e3

Please sign in to comment.