Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TZUP-24: Implement API to define Budget file: #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
TZ UPGRADE / 2020-09-21
=================
* [TZUP-24](https://openlmis.atlassian.net/browse/TZUP-24): Implement API to define Budget file:

8.2.0 / WIP
=================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class FileTemplateControllerIntegrationTest extends BaseWebIntegrationTes

private static final String RESOURCE_URL = "/api/fileTemplates";
private static final String ORDER = "ORDER";
private static final String BUDGET = "BUDGET";
private static final String TEMPLATE_TYPE = "templateType";

private FileTemplate fileTemplate = new FileTemplate();
Expand Down Expand Up @@ -270,4 +271,25 @@ public void shouldReturn403WhenUserHasNoRightsToViewOrderFileTemplate() {

assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
}


@Test
public void shouldReturnBudgetFileTemplate() {
given(fileTemplateService.getFileTemplate(TemplateType.BUDGET))
.willReturn(fileTemplate);

FileTemplateDto result = restAssured.given()
.queryParam(TEMPLATE_TYPE, BUDGET)
.header(HttpHeaders.AUTHORIZATION, getTokenHeader())
.contentType(MediaType.APPLICATION_JSON_VALUE)
.when()
.get(RESOURCE_URL)
.then()
.statusCode(200)
.extract()
.as(FileTemplateDto.class);

assertEquals(fileTemplate.getId(),result.getId());
assertThat(RAML_ASSERT_MESSAGE, restAssured.getLastReport(), RamlMatchers.hasNoViolations());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@

public enum TemplateType {
ORDER,
SHIPMENT
SHIPMENT,
BUDGET
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


INSERT INTO file_templates (id, fileprefix, headerinfile, templatetype) VALUES ('8280fc97-a44d-4630-9f42-fb343838eb39', 'B', true, 'BUDGET');


INSERT INTO file_columns (id, columnlabel, datafieldlabel, format, include, keypath, nested, openlmisfield, "position", related, relatedkeypath, filetemplateid) VALUES('868eed77-4ab5-4211-a8e6-c25d8a4f2816', 'Name', 'fulfillment.header.budget.name', NULL, true, 'name', 'name', true, 1, NULL, NULL, '8280fc97-a44d-4630-9f42-fb343838eb39');
INSERT INTO file_columns (id, columnlabel, datafieldlabel, format, include, keypath, nested, openlmisfield, "position", related, relatedkeypath, filetemplateid) VALUES ('39ee56fb-2aa2-472c-b3b5-abf9befa5c34', 'Zone', 'fulfillment.header.budget.zone', NULL, true, 'zone', 'zone', true, 2, 'zone', 'zone', '8280fc97-a44d-4630-9f42-fb343838eb39');
INSERT INTO file_columns (id, columnlabel, datafieldlabel, format, include, keypath, nested, openlmisfield, "position", related, relatedkeypath, filetemplateid) VALUES ('5940412a-0350-41ee-b4cb-eccaa2e6622c', 'Total Sales', 'fulfillment.header.budget.total.sales', NULL, true, 'totalSales', 'totalSales', true, 3, 'totalSales', 'totalSales', '8280fc97-a44d-4630-9f42-fb343838eb39');
INSERT INTO file_columns (id, columnlabel, datafieldlabel, format, include, keypath, nested, openlmisfield, "position", related, relatedkeypath, filetemplateid) VALUES ('63b23202-acff-451a-ac99-59b3b1d1d9f6', 'Total Deposits', 'fulfillment.header.budget.total.deposits', NULL, true, 'totalDeposits', 'totalDeposits', true, 4, 'totalDeposits', 'totalDeposits', '8280fc97-a44d-4630-9f42-fb343838eb39');
INSERT INTO file_columns (id, columnlabel, datafieldlabel, format, include, keypath, nested, openlmisfield, "position", related, relatedkeypath, filetemplateid) VALUES ('8b8e64e4-7e8e-4fed-bd41-d06892b5dde3', 'Opening Balance', 'fulfillment.header.budget.opening.balance', NULL, true, 'openingBalance', 'openingBalance', true, 5, NULL, NULL, '8280fc97-a44d-4630-9f42-fb343838eb39');
INSERT INTO file_columns (id, columnlabel, datafieldlabel, format, include, keypath, nested, openlmisfield, "position", related, relatedkeypath, filetemplateid) VALUES ('94dd7715-db20-4310-8f2a-b1477ee29468', 'Closing Balance', 'fulfillment.header.budget.closing.balance', NULL, true, 'closingBalance', 'closingBalance', true, 6, NULL, NULL, '8280fc97-a44d-4630-9f42-fb343838eb39');


8 changes: 8 additions & 0 deletions src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,11 @@ fulfillment.error.pageable.size.notPositive=The page size should be a positive n

# Javers
fulfillment.error.javers.entryAlreadyExists=Javers entry for the entity of class {0} and id {1} already exists.

fulfillment.header.budget.name= Name
fulfillment.header.budget.zone= Zone
fulfillment.header.budget.total.sales= Total Sales
fulfillment.header.budget.total.deposits= Total Deposits
fulfillment.header.budget.opening.balance= Opening Balance
fulfillment.header.budget.closing.balance= Closing Balance

48 changes: 18 additions & 30 deletions src/main/resources/schemas/fileTemplateDto.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
{ "type": "object",
"$schema": "http://json-schema.org/draft-04/schema",
"title": "FileTemplateDto",
"description": "A single FileTemplate",
"properties": {
"id": {
"type": ["string", "null"],
"title": "id"
},
"filePrefix": {
"type": "string",
"title": "filePrefix"
},
"headerInFile": {
"type": "boolean",
"title": "headerInFile"
},
"csvFileColumns": {
"type": "array",
"title": "csvFileColumns",
"items": {
"type": "object",
"$ref": "fileColumnDto.json"
},
"uniqueItems": false
{
"id": "object",
"filePrefix": "string",
"headerInFile": true,
"templateType": "object",
"fileColumns": [
{
"openLmisField": true,
"dataFieldLabel": "object",
"columnLabel": "Name",
"include": true,
"position": 1,
"format": "string",
"nested": "string",
"keyPath": "string",
"related": "string",
"relatedKeyPath": "string"
}
},
"required": [
"filePrefix",
"headerInFile"
]
}
}