-
Notifications
You must be signed in to change notification settings - Fork 9
Transactional Data Reimport Test #294
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
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
a112d49
Add ReimportTest notebook
0e6fa19
Restructure ReimportTest nb and add notes
bc0ad4f
Implement all requested cases, add data and assertions
7397513
Merge branch 'develop' into TransactionalDataReimport
4da2a21
Merge branch 'develop' into TransactionalDataReimport
f40bbcd
WIP in all cases except use case 3
c7d82ae
Merge branch 'develop' into TransactionalDataReimport
748e5f1
fix syntax in Instance()
f56ba03
More work in case 3 in imports, queries and assertions
20c66cc
Add new case and make ReimportTest pass
98e05b6
Cleanup
9aecc6f
Fix assertions
350530b
Add ReimportTest in Tests
30ab846
Merge branch 'develop' into TransactionalDataReimport
6624a04
Fix the used memory markdown 28Gb RAM
590b3a1
Merge branch 'develop' into TransactionalDataReimport
f4d0260
Fix case 3 assertion and clean up
b2de2ae
Merge branch 'develop' into TransactionalDataReimport
471e963
Clean up, implement feedback and update RAM md in Tests
fd943d1
Clean up x2
5352558
Feedback
c38a057
Merge branch 'develop' into TransactionalDataReimport
0d81cac
Restructuring and strictly keeping the "reimport" cases.
172a13f
Tests RAM markdown
027c01f
Merge branch 'develop' into TransactionalDataReimport
10d1b66
Feedback + test case proposal
aa541c5
Merge branch 'develop' into TransactionalDataReimport
cfd59c7
Merge branch 'develop' into TransactionalDataReimport
05060c9
Merge remote-tracking branch 'origin/develop' into TransactionalDataR…
bbbe255
Merge branch 'develop' into TransactionalDataReimport
aa9b40a
RAM md in Tests
57b31f7
Correct RAM in Tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,347 @@ | ||
| { | ||
| "metadata": { | ||
| "authors": [], | ||
| "id": "VOS67A7-B0Omk1s4TFC3LQ", | ||
| "kernelspec": { | ||
| "display_name": "Formula Framework", | ||
| "language": "C#", | ||
| "name": "C#" | ||
| }, | ||
| "language_info": { | ||
| "file_extension": ".cs", | ||
| "mimetype": "text/plain", | ||
| "name": "C#" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5, | ||
| "cells": [ | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "<p style=\"font-weight:bold;\"> <span style=\"font-size: 36px\"> Reimport of Transactional Data Test</span> </p>" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "#!eval-notebook \"../Initialization/InitSystemorphBaseToMemory\"" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "# Check Method" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "public async Task<ActivityLog> ReimportAndCompare((string transactionalData, string importFormat) importData, DataNodeState[] dataNodeStates)", | ||
| "\n{", | ||
| "\n var workspace = Workspace.CreateNew();", | ||
| "\n workspace.Initialize(x => x.FromSource(DataSource).DisableInitialization<DataNodeState>().DisableInitialization<IfrsVariable>().DisableInitialization<RawVariable>());", | ||
| "\n await workspace.UpdateAsync<DataNodeState>(dataNodeStates);", | ||
| "\n", | ||
| "\n Activity.Start();", | ||
| "\n var importActivity = await Import.FromString(importData.transactionalData).WithFormat(importData.importFormat).WithTarget(workspace).ExecuteAsync();", | ||
| "\n if(importActivity.RepeatOnce().ToArray().HasErrors()) return importActivity;", | ||
|
nnikolopoulos marked this conversation as resolved.
|
||
| "\n ", | ||
| "\n var firstImportRawVariable = workspace.Query<RawVariable>().ToArray();", | ||
| "\n var firstImportIfrsVariable = workspace.Query<IfrsVariable>().ToArray();", | ||
| "\n", | ||
| "\n var reimportActivity = await Import.FromString(importData.transactionalData).WithFormat(importData.importFormat).WithTarget(workspace).ExecuteAsync();", | ||
| "\n if(reimportActivity.RepeatOnce().ToArray().HasErrors()) return reimportActivity;", | ||
|
nnikolopoulos marked this conversation as resolved.
|
||
| "\n", | ||
| "\n var secondImportRawVariable = workspace.Query<RawVariable>().ToArray();", | ||
| "\n var secondImportIfrsVariable = workspace.Query<IfrsVariable>().ToArray();", | ||
| "\n", | ||
| "\n List<string> errors = new List<string>();", | ||
| "\n var missingRawVariables = firstImportRawVariable.Except(secondImportRawVariable, RawVariableComparer.Instance(ignoreValues: false));", | ||
| "\n var missingIfrsVariables = firstImportIfrsVariable.Except(secondImportIfrsVariable, IfrsVariableComparer.Instance(ignoreValues: false));", | ||
| "\n var extraRawVariables = secondImportRawVariable.Except(firstImportRawVariable, RawVariableComparer.Instance(ignoreValues: false));", | ||
| "\n var extraIfrsVariables = secondImportIfrsVariable.Except(firstImportIfrsVariable, IfrsVariableComparer.Instance(ignoreValues: false));", | ||
| "\n", | ||
| "\n if(missingRawVariables.Any()) errors.Add($\"Missing RawVariables after the reimport: {string.Join(\"\\n\", missingRawVariables.ToList())}.\");", | ||
| "\n if(missingIfrsVariables.Any()) errors.Add($\"Missing IfrsVariables after the reimport: {string.Join(\"\\n\", missingIfrsVariables.ToList())}.\");", | ||
| "\n if(extraRawVariables.Any()) errors.Add($\"Extra RawVariables after the reimport: {string.Join(\"\\n\", extraRawVariables.ToList())}.\");", | ||
| "\n if(extraIfrsVariables.Any()) errors.Add($\"Extra IfrsVariables after the reimport: {string.Join(\"\\n\", extraIfrsVariables.ToList())}.\");", | ||
| "\n ", | ||
| "\n if(errors.Any()) ApplicationMessage.Log(Error.Generic, string.Join(\"\\n\", errors));", | ||
| "\n", | ||
| "\n ApplicationMessage.Log(Warning.Generic, \"Count of IfrsVariables in workspace: \" + secondImportIfrsVariable.Count());", | ||
| "\n ApplicationMessage.Log(Warning.Generic, \"Count of RawVariables in workspace: \" + secondImportRawVariable.Count());", | ||
| "\n return Activity.Finish();", | ||
| "\n}" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "# Data Preparation" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "Create:", | ||
| "\n- Import args for current year (2021)", | ||
| "\n- Import args for previous year (2020)", | ||
| "\n- Partition by Reporting Node (using details from most recent args)" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "var args = new ImportArgs(\"CH\", 2021, 3, Periodicity.Quarterly, null, null);", | ||
| "\nvar previousArgs = new ImportArgs(\"CH\", 2020, 12, Periodicity.Quarterly, null, null);", | ||
| "\n", | ||
| "\nvar partitionByReportingNode = new PartitionByReportingNode { Id = (Guid)(await DataSource.Partition.GetKeyForInstanceAsync<PartitionByReportingNode>(args)), ReportingNode = args.ReportingNode };" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "Create 5 data node states:", | ||
| "\n- dt11StatePrevious", | ||
| "\n- dtr11StatePrevious", | ||
| "\n- dt11State", | ||
| "\n- dtr11State", | ||
| "\n- dt13State" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "var dt11StatePrevious = new DataNodeState { DataNode = \"DT1.1\", State = State.Active, Year = previousArgs.Year, Month = previousArgs.Month, Partition = partitionByReportingNode.Id };", | ||
| "\n", | ||
| "\nvar dtr11StatePrevious = new DataNodeState { DataNode = \"DTR1.1\", State = State.Active, Year = previousArgs.Year, Month = previousArgs.Month, Partition = partitionByReportingNode.Id };", | ||
| "\n", | ||
| "\nvar dt11State = new DataNodeState { DataNode = \"DT1.1\", State = State.Active, Year = args.Year, Month = args.Month, Partition = partitionByReportingNode.Id };", | ||
| "\n", | ||
| "\nvar dtr11State = new DataNodeState { DataNode = \"DTR1.1\", State = State.Active, Year = args.Year, Month = args.Month, Partition = partitionByReportingNode.Id };", | ||
| "\n", | ||
| "\nvar dt13State = new DataNodeState { DataNode = \"DT1.3\", State = State.Active, Year = args.Year, Month = args.Month, Partition = partitionByReportingNode.Id };" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "# Test Transactional Data" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "## Reimport Openings for DataNode at Inception" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "Create openings for a data node at inception (DT1.1) and import more than once." | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "var openings = @\"", | ||
| "\n@@Main,,,,", | ||
| "\nReportingNode,Year,Month,,", | ||
| "\nCH,2021,3,,", | ||
| "\n@@Opening,,,,", | ||
| "\nDataNode,EstimateType,AmountType,AccidentYear,Value", | ||
| "\nDT1.1,C,,,72.2", | ||
| "\nDT1.1,AA,PR,,-1.5", | ||
| "\nDT1.1,OA,PR,,1.5", | ||
| "\n\";" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "var activity = await ReimportAndCompare((openings, ImportFormats.Opening), new [] { dt11State, dtr11State });", | ||
| "\nactivity" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "## Reimport Actuals for Both: DataNode at Inception and DataNode Not at Inception" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "Create an actuals file that contains data for both a data node at inception (DT1.3) and a data node not at inception (DT1.1). ", | ||
| "\n", | ||
| "\nImport this file more than once." | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "var actuals = @\"", | ||
| "\n@@Main,,,,,", | ||
| "\nReportingNode,Year,Month,,,", | ||
| "\nCH,2021,3,,,", | ||
| "\n@@Actual,,,,,", | ||
| "\nDataNode,AocType,AmountType,EstimateType,AccidentYear,Value", | ||
| "\nDT1.1,CF,PR,A,,90", | ||
| "\nDT1.1,CF,ICO,A,,-6", | ||
| "\nDT1.1,CF,NIC,A,,-70", | ||
| "\nDT1.1,CF,ACA,A,,-10", | ||
| "\nDT1.1,CF,AEA,A,,-5", | ||
| "\nDT1.3,CF,PR,A,,90", | ||
| "\nDT1.3,CF,ICO,A,,-6", | ||
| "\nDT1.3,CF,NIC,A,,-70", | ||
| "\nDT1.3,CF,ACA,A,,-10", | ||
| "\nDT1.3,CF,AEA,A,,-5\";" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "var activity = await ReimportAndCompare((actuals, ImportFormats.Actual), new[] {dt11StatePrevious, dtr11StatePrevious, dt13State});", | ||
| "\nactivity" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "## Reimport Cashflows for Linked Reinsurance Not at Inception" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "source": [ | ||
| "Create a cashflows file that contains data for a data node not at inception (DTR1.1). ", | ||
| "\n", | ||
| "\nImport this file more than once." | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "var cashflows = @\"", | ||
| "\n@@Main,,,,,,,,,,,,,,,,,,,,,,,,,,", | ||
| "\nReportingNode,Year,Month,,,,,,,,,,,,,,,,,,,,,,,,", | ||
| "\nCH,2021,3,,,,,,,,,,,,,,,,,,,,,,,,", | ||
| "\n@@Cashflow,,,,,,,,,,,,,,,,,,,,,,,,,,", | ||
| "\nDataNode,AmountType,EstimateType,AocType,Novelty,AccidentYear,Values0,Values1,Values2,Values3,Values4,Values5,Values6,Values7,Values8,Values9,Values10,Values11,Values12,Values13,Values14,Values15,Values16,Values17,Values18,Values19,Values20", | ||
| "\nDTR1.1,PR,BE,CL,C,,0,-57.5,0,0,-57.5,0,0,-57.5,0,0,-57.5,0,0,0,0,0,0,0,0,0,0", | ||
| "\nDTR1.1,NIC,BE,CL,C,,15,15,15,15,15,15,15,15,15,15,15,15,0,0,0,0,0,0,0,0,0", | ||
| "\nDTR1.1,,RA,CL,C,,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,1.25,0,0,0,0,0,0,0,0,0\";" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "var activity = await ReimportAndCompare((cashflows, ImportFormats.Cashflow), new[] {dt11StatePrevious, dtr11StatePrevious});", | ||
| "\nactivity" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "activity.Status.Should().Be(ActivityLogStatus.Succeeded);" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "source": [ | ||
| "" | ||
| ], | ||
| "metadata": {}, | ||
| "execution_count": 0, | ||
| "outputs": [] | ||
| } | ||
| ] | ||
| } | ||
|
nnikolopoulos marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.