Skip to content

Commit

Permalink
VTA-1576: Generate Welsh Certificate PSV Pass (#92)
Browse files Browse the repository at this point in the history
* feat(vta-1576): added new models, updated enums and configs

* feat(vta-1576): corrected typo

* feat(vta-1576): added new tests

* feat(vta-1576): corrected formatting
  • Loading branch information
cb-cs authored Oct 9, 2023
1 parent fbc5dfe commit c2dc05e
Show file tree
Hide file tree
Showing 13 changed files with 852 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/main/java/uk/gov/dvsa/enums/CertificateTemplates.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum CertificateTemplates {
VT29("MOT/VT29"),

VTP20("CommercialVehicles/pass"),
VTP20W("CommercialVehicles/passWelsh"),
VTP30("CommercialVehicles/fail"),

VTG5("CommercialVehicles/passNoSeatbeltFields"),
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/uk/gov/dvsa/enums/CertificateTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public enum CertificateTypes {


CVS_PASS("CVS/VTP20"),
CVS_PASS_WELSH("CVS/VTP20W"),
CVS_PASS_BILINGUAL("CVS/VTP20_BILINGUAL"),
CVS_FAIL("CVS/VTP30"),
CVS_PSV_PRS("CVS/PSV_PRS"),

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/uk/gov/dvsa/enums/DocumentsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public enum DocumentsConfig {
new String[]{CertificateTemplates.VTP20.getCertificateTemplateName(), CertificateTemplates.VTP30.getCertificateTemplateName()}),
VTP20(CertificateTypes.CVS_PASS.getCertificateType(), uk.gov.dvsa.model.cvs.VTP20.class,
new String[]{CertificateTemplates.VTP20.getCertificateTemplateName()}),
VTP20W(CertificateTypes.CVS_PASS_WELSH.getCertificateType(), uk.gov.dvsa.model.cvs.VTP20W.class,
new String[]{CertificateTemplates.VTP20W.getCertificateTemplateName()}),
VTP30(CertificateTypes.CVS_FAIL.getCertificateType(), uk.gov.dvsa.model.cvs.VTP30.class,
new String[]{CertificateTemplates.VTP30.getCertificateTemplateName()}),

Expand All @@ -72,6 +74,8 @@ public enum DocumentsConfig {
new String[]{CertificateTemplates.RWT_DATA.getCertificateTemplateName()}),
CVS_HGV_PRS(CertificateTypes.CVS_HGV_PRS.getCertificateType(), uk.gov.dvsa.model.cvs.CvsHgvPRS.class,
new String[]{CertificateTemplates.VTG5.getCertificateTemplateName(), CertificateTemplates.VTG30.getCertificateTemplateName()}),
CVS_PASS_BILINGUAL(CertificateTypes.CVS_PASS_BILINGUAL.getCertificateType(), uk.gov.dvsa.model.cvs.CvsPsvPassBilingual.class,
new String[]{CertificateTemplates.VTP20.getCertificateTemplateName(), CertificateTemplates.VTP20W.getCertificateTemplateName()}),
CVS_HGV_PASS_BILINGUAL(CertificateTypes.CVS_HGV_PASS_BILINGUAL.getCertificateType(), uk.gov.dvsa.model.cvs.CvsHgvPassBilingual.class,
new String[]{CertificateTemplates.VTG5.getCertificateTemplateName(), CertificateTemplates.VTG5W.getCertificateTemplateName()}),
CVS_TRL_PASS_BILINGUAL(CertificateTypes.CVS_TRL_PASS_BILINGUAL.getCertificateType(), uk.gov.dvsa.model.cvs.CvsTrlPassBilingual.class,
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/uk/gov/dvsa/model/cvs/CvsPsvPassBilingual.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package uk.gov.dvsa.model.cvs;

public class CvsPsvPassBilingual extends VTP20W {

public String getTestType() {
return "PSV";
}

public String getPresentedDocumentNamePass() {
return "VTP20";
}

public String getPresentedDocumentNamePassWelsh() {
return "VTP20W";
}

public String getVersionNumberPass() {
return "1.0";
}

public String getVersionNumberPassWelsh() {
return "1.0";
}

public String getRegOrIdHeading() {
return "Registration number";
}
}
28 changes: 28 additions & 0 deletions src/main/java/uk/gov/dvsa/model/cvs/VTP20W.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package uk.gov.dvsa.model.cvs;

import uk.gov.dvsa.model.Document;
import uk.gov.dvsa.model.cvs.certificateData.CvsMotCertificateDataWelsh;

public class VTP20W extends CvsMotCertificate {

public Document setData(CvsMotCertificateDataWelsh data) {
this.data = data;
return this;
}

public String getTestType() {
return "PSV";
}

public String getPresentedDocumentNamePass() {
return "VTP20W";
}

public String getVersionNumberPass() {
return "1.0";
}

public String getRegOrIdHeadingWelsh() {
return "Rhif cofrestru";
}
}
22 changes: 11 additions & 11 deletions src/main/resources/views/CommercialVehicles/passWelsh.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</div>
<div class="footer__certificate-tag">
<span class="footer__certificate-tag-text">
{{presentedDocumentNamePass}}/{{versionNumberPass}}
{{presentedDocumentNamePassWelsh}}/{{versionNumberPassWelsh}}
</span>
</div>
</div>
Expand Down Expand Up @@ -70,7 +70,7 @@
</div>
<div class="footer__certificate-tag">
<span class="footer__certificate-tag-text">
{{presentedDocumentNamePass}}/{{versionNumberPass}}
{{presentedDocumentNamePassWelsh}}/{{versionNumberPassWelsh}}
</span>
</div>
</div>
Expand Down Expand Up @@ -120,7 +120,7 @@
</span>
<span class="heading-info__title-right">
<span class="heading-info__title-message">
{{regOrIdHeading}}
{{regOrIdHeadingWelsh}}
</span>
</span>
</h2>
Expand Down Expand Up @@ -167,7 +167,7 @@
<!-- /heading-info -->
</div>
<div class="header__right">
<img src="{{root}}/assets/images/dvsa_crest.png" alt="DVSA Crown" class="header__logo" id="logo"/>
<img src="{{root}}/assets/images/dvsa-crest-welsh-v2.png" alt="DVSA Crown" class="header__logo" id="logo"/>
</div>
<div class="clearfix"></div>
<!-- header__three-columns -->
Expand All @@ -193,7 +193,7 @@
</div>
<!-- /heading-info -->
</div>
{{#if data.formattedCurrentOdometer}}
{{#if data.formattedCurrentOdometerWelsh}}
<div class="header__three-columns-two">
<!-- heading-info -->
<div class="heading-info">
Expand All @@ -210,7 +210,7 @@
</span>
</h2>
<span class="heading-info__content" id="mileage">
{{data.formattedCurrentOdometer}}
{{data.formattedCurrentOdometerWelsh}}
</span>
</div>
<!-- /heading-info -->
Expand All @@ -228,7 +228,7 @@
<!-- header__histories -->
{{#if data.odometerHistoryList}}
<ul class="header__histories">
{{#each data.mileageHistory}}
{{#each data.mileageHistoryWelsh}}
<li class="header__history">
<div class="header__history-left-wide">
<span class="header__history-mileage">
Expand Down Expand Up @@ -260,12 +260,12 @@
<!-- results -->
<div class="results">
<div class="results__wrapper">
{{~> views/CommercialVehicles/reasonsForRejection data.summary}}
{{~> views/CommercialVehicles/reasonsForRejection data.summaryWelsh}}
{{#if data.minor.present}}
{{~> views/CommercialVehicles/reasonsForRejection data.minor}}
{{~> views/CommercialVehicles/reasonsForRejection data.minorWelsh}}
{{/if}}
{{#if data.advisory.present}}
{{~> views/CommercialVehicles/reasonsForRejection data.advisory}}
{{~> views/CommercialVehicles/reasonsForRejection data.advisoryWelsh}}
{{/if}}
</div>
</div>
Expand Down Expand Up @@ -357,7 +357,7 @@
</h2>
<span class="heading-info__content"
id="organisation-and-inspection-name">
{{data.testingOrganisation}}
{{data.testingOrganisationWelsh}}
<br/>
{{data.issuersName}}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ public static VTP20 getReplacementVtp20() {
return document;
}

public static VTP20W getVtp20wWithNoOdometerHistory() {
VTP20W document = getVtp20W();

CvsMotCertificateData data = document.getData();
data.setOdometerHistoryList(null);

return document;
}

public static VTP20 getVtp20() {
VTP20 vtp20 = new VTP20();
vtp20.setDocumentName(CertificateTypes.CVS_PASS.getCertificateType());
Expand Down Expand Up @@ -95,6 +104,56 @@ public static VTP20 getVtp20() {
return vtp20;
}

public static VTP20W getVtp20W() {
VTP20W vtp20W = new VTP20W();
vtp20W.setDocumentName(CertificateTypes.CVS_PASS_WELSH.getCertificateType());
CvsMotCertificateDataWelsh vtp20WData = new CvsMotCertificateDataWelsh();
vtp20WData
.setMinorDefectsWelsh(generateRFRs(MINOR_RFR_TEXT, 1))
.setAdvisoryDefectsWelsh(generateRFRs(ADVISORY_RFR_TEXT, 1))
.setMinorDefectsHeader(DefectSummaryComponent.MINOR_DEFECTS_HEADER_TEST_WELSH_CVS)
.setAdvisoryDefectsHeader(DefectSummaryComponent.ADVISORIES_HEADER_TEXT_WELSH_CVS)
.setMinorDefects(generateRFRs(MINOR_RFR_TEXT, 1))
.setAdvisoryDefects(generateRFRs(ADVISORY_RFR_TEXT, 1))

.setSeatBeltNumber("10")
.setSeatBeltPreviousCheckDate("12.11.2018")
.setSeatBeltTested("Yes")

.setCountryOfRegistrationCode("GB")
.setRawVin(VIN)
.setDateOfTheTest("12.11.2018")
.setExpiryDate("12.10.2018")
.setTestStationPNumber("P12345")
.setTestStationName("TEST STATION NAME")
.setMake("Aston Martin")
.setModel("DB11")
.setVehicleEuClassification("M1")
.setRawVrm("KA1SAPH")
.setCurrentOdometer(
new CvsOdometerReading("22341", "mi", "01.02.2019")
)
.setOdometerHistoryList(Arrays.asList(
new CvsOdometerReading("120", "mi", "01.02.2016"),
new CvsOdometerReading("330", "mi", "30.01.2017")
))
.setIssuersName("R.DREWNO")
.setTestStationName("POPULAR GARAGES")
.setTestNumber("1806 8140 0628")
.setEarliestDateOfTheNextTest("13.10.2018");

vtp20W.setData(vtp20WData);

Signature signature = new Signature();
signature
.setImageData("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==")
.setImageType("png");

vtp20W.setSignature(signature);

return vtp20W;
}

private static Reissue generateReissuer() {
Reissue reissue = new Reissue();
reissue.setIssuer("Joe");
Expand Down Expand Up @@ -239,7 +298,6 @@ public static VTG5A getVtg5a() {
.setMake("Aston Martin")
.setModel("DB11")
.setIssuersName("R.DREWNO")
.setTestStationName("POPULAR GARAGES")
.setTestNumber("1806 8140 0628")
.setEarliestDateOfTheNextTest("13.10.2018")
.setTrn("ABC1234")
Expand Down Expand Up @@ -306,6 +364,46 @@ public static VTG5W getVTG5W() {
return vtg5W;
}

public static VTG5AW getVTG5AW() {
VTG5AW vtg5AW = new VTG5AW();
vtg5AW.setDocumentName(CertificateTypes.CVS_TRL_PASS_WELSH.getCertificateType());
CvsMotCertificateDataWelsh vtg5AWData = new CvsMotCertificateDataWelsh();
vtg5AWData
.setMinorDefectsWelsh(generateRFRs(MINOR_RFR_TEXT, 1))
.setAdvisoryDefectsWelsh(generateRFRs(ADVISORY_RFR_TEXT, 1))
.setMinorDefectsHeader(DefectSummaryComponent.MINOR_DEFECTS_HEADER_TEST_WELSH_CVS)
.setAdvisoryDefectsHeader(DefectSummaryComponent.ADVISORIES_HEADER_TEXT_WELSH_CVS)
.setMinorDefects(generateRFRs(MINOR_RFR_TEXT, 1))
.setAdvisoryDefects(generateRFRs(ADVISORY_RFR_TEXT, 1))

.setCountryOfRegistrationCode("GB")
.setRawVin(VIN)
.setDateOfTheTest("12.11.2018")
.setExpiryDate("12.10.2018")
.setTestStationPNumber("P12345")
.setTestStationName("TEST STATION NAME")
.setMake("Aston Martin")
.setModel("DB11")
.setIssuersName("R.DREWNO")
.setTestStationName("POPULAR GARAGES")
.setTestNumber("1806 8140 0628")
.setEarliestDateOfTheNextTest("13.10.2018")
.setTrn("ABC1234")
.setIsTrailer(true);

vtg5AW.setData(vtg5AWData);

Signature signature = new Signature();
signature
.setImageData("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==")
.setImageType("png");

vtg5AW.setSignature(signature);
vtg5AW.setReissue(generateReissuer());

return vtg5AW;
}

public static CvsHgvPassBilingual getCvsHgvPassBilingual() {
CvsHgvPassBilingual hgvPassBilingual = new CvsHgvPassBilingual();
hgvPassBilingual.setDocumentName(CertificateTypes.CVS_HGV_PASS_BILINGUAL.getCertificateType());
Expand All @@ -319,7 +417,6 @@ public static CvsHgvPassBilingual getCvsHgvPassBilingual() {
.setMinorDefects(generateRFRs(MINOR_RFR_TEXT, 1))
.setAdvisoryDefects(generateRFRs(ADVISORY_RFR_TEXT, 1))


.setCountryOfRegistrationCode("GB")
.setRawVin(VIN)
.setDateOfTheTest("22.08.2023")
Expand Down Expand Up @@ -347,6 +444,81 @@ public static CvsHgvPassBilingual getCvsHgvPassBilingual() {
return hgvPassBilingual;
}

public static CvsPsvPassBilingual getCvsPsvPassBilingual() {
CvsPsvPassBilingual psvPassBilingual = new CvsPsvPassBilingual();
psvPassBilingual.setDocumentName(CertificateTypes.CVS_PASS_BILINGUAL.getCertificateType());

CvsMotCertificateDataWelsh bilingualData = new CvsMotCertificateDataWelsh();
bilingualData
.setMinorDefectsWelsh(generateRFRs(MINOR_RFR_TEXT, 1))
.setAdvisoryDefectsWelsh(generateRFRs(ADVISORY_RFR_TEXT, 1))
.setMinorDefectsHeader(DefectSummaryComponent.MINOR_DEFECTS_HEADER_TEST_WELSH_CVS)
.setAdvisoryDefectsHeader(DefectSummaryComponent.ADVISORIES_HEADER_TEXT_WELSH_CVS)
.setMinorDefects(generateRFRs(MINOR_RFR_TEXT, 1))
.setAdvisoryDefects(generateRFRs(ADVISORY_RFR_TEXT, 1))

.setSeatBeltNumber("10")
.setSeatBeltPreviousCheckDate("12.11.2018")
.setSeatBeltTested("Yes")

.setCountryOfRegistrationCode("GB")
.setRawVin(VIN)
.setDateOfTheTest("12.11.2018")
.setExpiryDate("12.10.2018")
.setTestStationPNumber("P12345")
.setTestStationName("TEST STATION NAME")
.setMake("Aston Martin")
.setModel("DB11")
.setVehicleEuClassification("M1")
.setRawVrm("KA1SAPH")
.setCurrentOdometer(
new CvsOdometerReading("22341", "mi", "01.02.2019")
)
.setOdometerHistoryList(Arrays.asList(
new CvsOdometerReading("120", "km", "01.02.2016"),
new CvsOdometerReading("330", "km", "30.01.2017")
))
.setIssuersName("R.DREWNO")
.setTestStationName("POPULAR GARAGES")
.setTestNumber("1806 8140 0628")
.setEarliestDateOfTheNextTest("13.10.2018");

psvPassBilingual.setData(bilingualData);
return psvPassBilingual;
}

public static CvsTrlPassBilingual getCvsTrlPassBilingual() {
CvsTrlPassBilingual trlPassBilingual = new CvsTrlPassBilingual();
trlPassBilingual.setDocumentName(CertificateTypes.CVS_TRL_PASS_BILINGUAL.getCertificateType());

CvsMotCertificateDataWelsh bilingualData = new CvsMotCertificateDataWelsh();
bilingualData
.setMinorDefectsWelsh(generateRFRs(MINOR_RFR_TEXT, 1))
.setAdvisoryDefectsWelsh(generateRFRs(ADVISORY_RFR_TEXT, 1))
.setMinorDefectsHeader(DefectSummaryComponent.MINOR_DEFECTS_HEADER_TEST_WELSH_CVS)
.setAdvisoryDefectsHeader(DefectSummaryComponent.ADVISORIES_HEADER_TEXT_WELSH_CVS)
.setMinorDefects(generateRFRs(MINOR_RFR_TEXT, 1))
.setAdvisoryDefects(generateRFRs(ADVISORY_RFR_TEXT, 1))

.setCountryOfRegistrationCode("GB")
.setRawVin(VIN)
.setDateOfTheTest("12.11.2018")
.setExpiryDate("12.10.2018")
.setTestStationPNumber("P12345")
.setTestStationName("TEST STATION NAME")
.setMake("Aston Martin")
.setModel("DB11")
.setIssuersName("R.DREWNO")
.setTestStationName("POPULAR GARAGES")
.setTestNumber("1806 8140 0628")
.setEarliestDateOfTheNextTest("13.10.2018")
.setTrn("ABC1234")
.setIsTrailer(true);

trlPassBilingual.setData(bilingualData);
return trlPassBilingual;
}

public static VTG5 getVtg5HavingInvalidXMLCharacter() {
VTG5 document = getVtg5();

Expand Down
Loading

0 comments on commit c2dc05e

Please sign in to comment.