Skip to content

Commit

Permalink
Added QualityControl service + test
Browse files Browse the repository at this point in the history
  • Loading branch information
cgendreau committed Dec 3, 2024
1 parent 1c6286d commit 24307f4
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class QualityControl implements DinaEntity {

@NotBlank
@Size(max = 50)
@Column(name = "qc_type")
private String qcType;

@ManyToOne(fetch = FetchType.LAZY)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ca.gc.aafc.seqdb.api.service;

import lombok.NonNull;

import org.springframework.stereotype.Service;
import org.springframework.validation.SmartValidator;

import ca.gc.aafc.dina.jpa.BaseDAO;
import ca.gc.aafc.dina.service.DefaultDinaService;
import ca.gc.aafc.dina.util.UUIDHelper;
import ca.gc.aafc.seqdb.api.entities.QualityControl;

@Service
public class QualityControlService extends DefaultDinaService<QualityControl> {

public QualityControlService(
@NonNull BaseDAO baseDAO,
@NonNull SmartValidator sv) {
super(baseDAO, sv);
}

@Override
protected void preCreate(QualityControl entity) {
entity.setUuid(UUIDHelper.generateUUIDv7());
}

}
4 changes: 4 additions & 0 deletions src/test/java/ca/gc/aafc/seqdb/api/SequenceModuleBaseIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ca.gc.aafc.seqdb.api.service.MolecularAnalysisRunService;
import ca.gc.aafc.seqdb.api.service.PcrBatchItemService;
import ca.gc.aafc.seqdb.api.service.PcrBatchService;
import ca.gc.aafc.seqdb.api.service.QualityControlService;
import ca.gc.aafc.seqdb.api.service.SeqSubmissionService;
import ca.gc.aafc.seqdb.api.service.SequenceManagedAttributeService;
import ca.gc.aafc.seqdb.api.service.SequencingFacilityService;
Expand Down Expand Up @@ -45,4 +46,7 @@ public class SequenceModuleBaseIT extends BaseIntegrationTest {
@Inject
protected SequenceManagedAttributeService managedAttributeService;

@Inject
protected QualityControlService qualityControlService;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ca.gc.aafc.seqdb.api.service;

import org.junit.jupiter.api.Test;

import ca.gc.aafc.seqdb.api.SequenceModuleBaseIT;
import ca.gc.aafc.seqdb.api.entities.QualityControl;
import ca.gc.aafc.seqdb.api.testsupport.factories.QualityControlFactory;

public class QualityControlServiceIT extends SequenceModuleBaseIT {

@Test
public void onValidEntity_save_noException() {
QualityControl qc = QualityControlFactory.newQualityControl().build();
qualityControlService.create(qc);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ca.gc.aafc.seqdb.api.testsupport.factories;

import ca.gc.aafc.dina.util.UUIDHelper;
import ca.gc.aafc.seqdb.api.entities.QualityControl;

public class QualityControlFactory {

public static QualityControl.QualityControlBuilder newQualityControl() {
return QualityControl.builder()
.name(TestableEntityFactory.generateRandomName(7))
.qcType("standard")
.uuid(UUIDHelper.generateUUIDv7())
.group("dina")
.createdBy("test user");
}
}

0 comments on commit 24307f4

Please sign in to comment.