use of org.hisp.dhis.webapi.controller.json.JsonMetadataProposal in project dhis2-core by dhis2.
the class MetadataWorkflowControllerTest method testMakeRemoveProposal.
@Test
void testMakeRemoveProposal() {
String proposalId = postRemoveProposal(defaultTargetId);
JsonMetadataProposal proposal = GET("/metadata/proposals/{uid}", proposalId).content().asObject(JsonMetadataProposal.class);
assertEquals(MetadataProposalStatus.PROPOSED, proposal.getStatus());
assertEquals(MetadataProposalType.REMOVE, proposal.getType());
assertEquals(MetadataProposalTarget.ORGANISATION_UNIT, proposal.getTarget());
assertEquals(defaultTargetId, proposal.getTargetId());
assertNotNull(proposal.getCreated());
assertNotNull(proposal.getCreatedBy());
assertNull(proposal.getFinalisedBy());
assertNull(proposal.getFinalised());
assertNull(proposal.getComment());
assertNull(proposal.getReason());
assertTrue(proposal.getChange().isUndefined());
}
use of org.hisp.dhis.webapi.controller.json.JsonMetadataProposal in project dhis2-core by dhis2.
the class MetadataWorkflowControllerTest method testAcceptProposal_ConflictTargetAlreadyDeleted.
@Test
void testAcceptProposal_ConflictTargetAlreadyDeleted() {
String proposalId = postRemoveProposal(defaultTargetId);
assertStatus(HttpStatus.OK, DELETE("/organisationUnits/" + defaultTargetId));
assertStatus(HttpStatus.CONFLICT, POST("/metadata/proposals/" + proposalId));
JsonMetadataProposal proposal = GET("/metadata/proposals/{uid}", proposalId).content().asObject(JsonMetadataProposal.class);
assertEquals(MetadataProposalStatus.NEEDS_UPDATE, proposal.getStatus());
assertNotNull(proposal.getReason());
assertWebMessage("Conflict", 409, "ERROR", "Proposal must be in status PROPOSED for this action", POST("/metadata/proposals/" + proposalId).content(HttpStatus.CONFLICT));
}
use of org.hisp.dhis.webapi.controller.json.JsonMetadataProposal in project dhis2-core by dhis2.
the class MetadataWorkflowControllerTest method testAcceptProposal_ConflictMissingAuthority.
@Test
void testAcceptProposal_ConflictMissingAuthority() {
User guest = switchToNewUser("guest");
String proposalId = postUpdateNameProposal(defaultTargetId, "New name");
JsonWebMessage message = assertWebMessage("Conflict", 409, "WARNING", "One more more errors occurred, please see full details in import report.", POST("/metadata/proposals/" + proposalId).content(HttpStatus.CONFLICT));
JsonErrorReport error = message.find(JsonErrorReport.class, report -> report.getErrorCode() == ErrorCode.E3001);
JsonMetadataProposal proposal = GET("/metadata/proposals/" + proposalId).content().as(JsonMetadataProposal.class);
assertEquals(String.format("E3001 User `guest guest [%s] (User)` is not allowed to update object `New name [%s] (OrganisationUnit)`.\n", guest.getUid(), defaultTargetId), proposal.getReason());
// but the system could accept the proposal
switchContextToUser(system);
assertStatus(HttpStatus.OK, PUT("/metadata/proposals/" + proposalId));
assertStatus(HttpStatus.OK, POST("/metadata/proposals/" + proposalId));
}
use of org.hisp.dhis.webapi.controller.json.JsonMetadataProposal in project dhis2-core by dhis2.
the class MetadataWorkflowControllerTest method testMakeAddProposal.
@Test
void testMakeAddProposal() {
String proposalId = postAddProposal("My Unit", "OU1");
JsonMetadataProposal proposal = GET("/metadata/proposals/{uid}", proposalId).content().asObject(JsonMetadataProposal.class);
assertEquals(MetadataProposalStatus.PROPOSED, proposal.getStatus());
assertEquals(MetadataProposalType.ADD, proposal.getType());
assertEquals(MetadataProposalTarget.ORGANISATION_UNIT, proposal.getTarget());
assertNull(proposal.getTargetId());
assertNotNull(proposal.getCreated());
assertNotNull(proposal.getCreatedBy());
assertNull(proposal.getFinalisedBy());
assertNull(proposal.getFinalised());
assertEquals("We need it", proposal.getComment());
assertNull(proposal.getReason());
assertTrue(proposal.getChange().isObject());
}
use of org.hisp.dhis.webapi.controller.json.JsonMetadataProposal in project dhis2-core by dhis2.
the class MetadataWorkflowControllerTest method testRejectProposal.
@Test
void testRejectProposal() {
String proposalId = postRemoveProposal(defaultTargetId);
// reject
assertStatus(HttpStatus.NO_CONTENT, DELETE("/metadata/proposals/" + proposalId));
JsonMetadataProposal proposal = GET("/metadata/proposals/{uid}", proposalId).content().asObject(JsonMetadataProposal.class);
assertEquals(MetadataProposalStatus.REJECTED, proposal.getStatus());
assertNotNull(proposal.getFinalisedBy());
assertNotNull(proposal.getFinalised());
}
Aggregations