Search in sources :

Example 1 with JsonMetadataProposal

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());
}
Also used : JsonOrganisationUnit(org.hisp.dhis.webapi.json.domain.JsonOrganisationUnit) JsonMetadataProposal(org.hisp.dhis.webapi.controller.json.JsonMetadataProposal) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 2 with JsonMetadataProposal

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());
}
Also used : JsonMetadataProposal(org.hisp.dhis.webapi.controller.json.JsonMetadataProposal) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 3 with JsonMetadataProposal

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());
}
Also used : JsonMetadataProposal(org.hisp.dhis.webapi.controller.json.JsonMetadataProposal) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 4 with JsonMetadataProposal

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());
}
Also used : JsonMetadataProposal(org.hisp.dhis.webapi.controller.json.JsonMetadataProposal) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 5 with JsonMetadataProposal

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());
}
Also used : JsonOrganisationUnit(org.hisp.dhis.webapi.json.domain.JsonOrganisationUnit) JsonMetadataProposal(org.hisp.dhis.webapi.controller.json.JsonMetadataProposal) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Aggregations

DhisControllerConvenienceTest (org.hisp.dhis.webapi.DhisControllerConvenienceTest)12 JsonMetadataProposal (org.hisp.dhis.webapi.controller.json.JsonMetadataProposal)12 Test (org.junit.jupiter.api.Test)12 JsonOrganisationUnit (org.hisp.dhis.webapi.json.domain.JsonOrganisationUnit)2 User (org.hisp.dhis.user.User)1 JsonErrorReport (org.hisp.dhis.webapi.json.domain.JsonErrorReport)1 JsonWebMessage (org.hisp.dhis.webapi.json.domain.JsonWebMessage)1