use of org.hisp.dhis.feedback.ErrorCode.E4051 in project dhis2-core by dhis2.
the class ProgramRuleVariableObjectBundleHookTest method shouldFailUpdateExistingDifferentUid.
@Test
void shouldFailUpdateExistingDifferentUid() {
when(programRuleVariable.getProgram()).thenReturn(program);
when(objectBundle.getImportMode()).thenReturn(ImportStrategy.CREATE_AND_UPDATE);
ProgramRuleVariable existingProgramRuleVariable = new ProgramRuleVariable();
existingProgramRuleVariable.setName("word");
existingProgramRuleVariable.setUid("uid1");
when(query.getResultList()).thenReturn(Collections.singletonList(existingProgramRuleVariable));
when(programRuleVariable.getName()).thenReturn("word");
when(programRuleVariable.getUid()).thenReturn("uid2");
List<ErrorReport> errorReports = programRuleVariableObjectBundleHook.validate(programRuleVariable, objectBundle);
assertEquals(1, errorReports.size());
assertTrue(errorReports.stream().anyMatch(e -> e.getErrorCode().equals(E4051)));
}
Aggregations