use of org.hisp.dhis.webapi.controller.json.JsonMetadataProposal in project dhis2-core by dhis2.
the class MetadataWorkflowControllerTest method testAcceptUpdateProposal.
@Test
void testAcceptUpdateProposal() {
String proposalId = postUpdateNameProposal(defaultTargetId, "New name");
assertStatus(HttpStatus.OK, POST("/metadata/proposals/" + proposalId));
JsonOrganisationUnit ou = GET("/organisationUnits/{uid}", defaultTargetId).content().as(JsonOrganisationUnit.class);
assertEquals("New name", ou.getName());
JsonMetadataProposal proposal = GET("/metadata/proposals/{uid}", proposalId).content().asObject(JsonMetadataProposal.class);
assertEquals(MetadataProposalStatus.ACCEPTED, proposal.getStatus());
assertNotNull(proposal.getFinalisedBy());
assertNotNull(proposal.getFinalised());
}
use of org.hisp.dhis.webapi.controller.json.JsonMetadataProposal in project dhis2-core by dhis2.
the class MetadataWorkflowControllerTest method testGetProposal.
@Test
void testGetProposal() {
String proposalId = postAddProposal("My Unit", "OU2");
JsonMetadataProposal proposal = GET("/metadata/proposals/{uid}", proposalId).content().asObject(JsonMetadataProposal.class);
assertTrue(proposal.exists());
}
use of org.hisp.dhis.webapi.controller.json.JsonMetadataProposal in project dhis2-core by dhis2.
the class MetadataWorkflowControllerTest method testAdjustProposal.
@Test
void testAdjustProposal() {
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);
assertNotNull(proposal.getReason());
assertEquals(MetadataProposalStatus.NEEDS_UPDATE, proposal.getStatus());
String ouId = assertStatus(HttpStatus.CREATED, POST("/organisationUnits/", "{'name':'My New Unit', 'shortName':'OU2', 'openingDate': '2020-01-01'}"));
assertStatus(HttpStatus.OK, PUT("/metadata/proposals/" + proposalId, "{'targetId':'" + ouId + "'}"));
proposal = GET("/metadata/proposals/{uid}", proposalId).content().asObject(JsonMetadataProposal.class);
assertEquals(MetadataProposalStatus.PROPOSED, proposal.getStatus());
assertEquals(ouId, proposal.getTargetId());
}
use of org.hisp.dhis.webapi.controller.json.JsonMetadataProposal in project dhis2-core by dhis2.
the class MetadataWorkflowControllerTest method testOpposeProposal.
@Test
void testOpposeProposal() {
String proposalId = postRemoveProposal(defaultTargetId);
assertStatus(HttpStatus.NO_CONTENT, PATCH("/metadata/proposals/" + proposalId, Body("Just NO!"), ContentType(MediaType.TEXT_PLAIN)));
JsonMetadataProposal proposal = GET("/metadata/proposals/{uid}", proposalId).content().asObject(JsonMetadataProposal.class);
assertEquals("Just NO!", proposal.getReason());
assertEquals(MetadataProposalStatus.NEEDS_UPDATE, proposal.getStatus());
}
use of org.hisp.dhis.webapi.controller.json.JsonMetadataProposal in project dhis2-core by dhis2.
the class MetadataWorkflowControllerTest method testAcceptAddProposal.
@Test
void testAcceptAddProposal() {
String proposalId = postAddProposal("My OU", "OU1");
String ouId = assertStatus(HttpStatus.CREATED, POST("/metadata/proposals/" + proposalId));
JsonOrganisationUnit ou = GET("/organisationUnits/{uid}", ouId).content().as(JsonOrganisationUnit.class);
assertEquals("My OU", ou.getName());
JsonMetadataProposal proposal = GET("/metadata/proposals/{uid}", proposalId).content().asObject(JsonMetadataProposal.class);
assertEquals(MetadataProposalStatus.ACCEPTED, proposal.getStatus());
assertNotNull(proposal.getFinalisedBy());
assertNotNull(proposal.getFinalised());
}
Aggregations