use of org.openmrs.module.idgen.service.BaseIdentifierSourceService in project openmrs-module-pihcore by PIH.
the class KghIdGeneratorProcessorTest method setup.
@Before
public void setup() throws Exception {
mockStatic(Context.class);
testDate = new SimpleDateFormat("yyyy-MM-dd").parse("2020-01-31");
generator = new SequentialIdentifierGenerator();
generator.setName("KGH ID Identifier Generator");
generator.setUuid(ConfigureSierraLeoneIdGenerators.KGH_ID_IDENTIFIER_SOURCE_UUID);
generator.setPrefix("'KGH'yyMM");
generator.setMinLength(11);
generator.setMaxLength(12);
generator.setBaseCharacterSet("1234567890");
generator.setFirstIdentifierBase("0001");
lastLogEntry = new LogEntry(generator, "KGH2019120012", testDate, new User(), "Test");
processor = new KghIdGeneratorProcessor() {
public Date getDate() {
return testDate;
}
};
processor.setIdentifierSourceService(new BaseIdentifierSourceService() {
long nextSequenceNum = 1L;
public void saveSequenceValue(SequentialIdentifierGenerator sequentialIdentifierGenerator, long l) {
nextSequenceNum = l;
lastLogEntry.setIdentifier("KGH" + new SimpleDateFormat("yyMM").format(testDate));
}
public Long getSequenceValue(SequentialIdentifierGenerator sequentialIdentifierGenerator) {
return nextSequenceNum;
}
public LogEntry getMostRecentLogEntry(IdentifierSource source) throws APIException {
return lastLogEntry;
}
});
}
Aggregations