-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCRNoMatch.cs
186 lines (153 loc) · 7.17 KB
/
CRNoMatch.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
using Btms.Common.Extensions;
using Btms.Model;
using Btms.Types.Alvs;
using Btms.Types.Ipaffs;
using Microsoft.Extensions.Logging;
using TestDataGenerator.Extensions;
using TestDataGenerator.Helpers;
using Decision = Btms.Types.Alvs.Decision;
namespace TestDataGenerator.Scenarios;
public static class NoMatchExtensions
{
public static AlvsClearanceRequest CompleteSimpleClearanceRequest(int scenario, int item, DateTime entryDate, ScenarioConfig config)
{
return NoMatchExtensions
.SimpleClearanceRequest(scenario, item, entryDate, config)
.ValidateAndBuild();
}
public static ClearanceRequestBuilder<AlvsClearanceRequest> SimpleClearanceRequest(int scenario, int item, DateTime entryDate, ScenarioConfig config)
{
return BuilderHelpers.GetClearanceRequestBuilder("cr-one-item")
.WithCreationDate(entryDate)
.WithArrivalDateTimeOffset(DateTime.Today.ToDate(), DateTime.Now.ToTime())
.WithReferenceNumberOneToOne(DataHelpers.GenerateReferenceNumber(ImportNotificationTypeEnum.Cveda, scenario,
entryDate, item))
.WithEntryVersionNumber()
.WithTunaItem();
}
public static MatchIdentifier DocumentReferenceFromFirstDoc(this AlvsClearanceRequest clearanceRequest)
{
return MatchIdentifier.FromCds(clearanceRequest
.Items?
.First()
.Documents?
.First()
.DocumentReference!);
}
public static DecisionBuilder<Decision> GetDecisionBuilder(
this AlvsClearanceRequest clearanceRequest)
{
var reference = clearanceRequest
.DocumentReferenceFromFirstDoc();
return BuilderHelpers.GetDecisionBuilder("decision-one-item")
.WithCreationDate(clearanceRequest.ServiceHeader!.ServiceCallTimestamp!.Value.AddHours(1), false)
.WithReferenceNumber(reference)
.WithEntryVersionNumber(1)
.WithDecisionVersionNumber()
.WithClearanceRequestDecisions(clearanceRequest);
}
}
public class CrNoMatchSingleItemWithDecisionScenarioGenerator(ILogger<CrNoMatchNoChecksScenarioGenerator> logger) : ScenarioGenerator
{
public override GeneratorResult Generate(int scenario, int item, DateTime entryDate, ScenarioConfig config)
{
var clearanceRequest = NoMatchExtensions
.SimpleClearanceRequest(scenario, item, entryDate, config)
.WithTunaItem()
.WithDispatchCountryCode("FR")
.ValidateAndBuild();
logger.LogInformation("Created {EntryReference}", clearanceRequest.Header!.EntryReference);
var alvsDecision = clearanceRequest
.GetDecisionBuilder()
.ValidateAndBuild();
logger.LogInformation("Created {EntryReference}", alvsDecision.Header!.EntryReference);
return new GeneratorResult([clearanceRequest, alvsDecision]);
}
}
public class CrNoMatchNoChecksScenarioGenerator(ILogger<CrNoMatchNoChecksScenarioGenerator> logger) : ScenarioGenerator
{
public override GeneratorResult Generate(int scenario, int item, DateTime entryDate, ScenarioConfig config)
{
var clearanceRequest = NoMatchExtensions
.SimpleClearanceRequest(scenario, item, entryDate, config)
.Do(cr =>
{
// Remove the checks from the items
cr.Items = cr.Items?
.Select(i =>
{
i.Checks = null;
return i;
})
.ToArray();
})
.ValidateAndBuild();
logger.LogInformation("Created {EntryReference}", clearanceRequest.Header!.EntryReference);
return new GeneratorResult([clearanceRequest]);
}
}
public class CrNoMatchNoDecisionScenarioGenerator(ILogger<CrNoMatchScenarioGenerator> logger) : ScenarioGenerator
{
public override GeneratorResult Generate(int scenario, int item, DateTime entryDate, ScenarioConfig config)
{
var reference = DataHelpers.GenerateReferenceNumber(ImportNotificationTypeEnum.Cveda, scenario, entryDate, item);
var clearanceRequest = NoMatchExtensions
.SimpleClearanceRequest(scenario, item, entryDate, config)
.WithReferenceNumberOneToOne(reference)
.WithRandomItems(10, 100)
.ValidateAndBuild();
logger.LogInformation("Created {EntryReference}", clearanceRequest.Header!.EntryReference);
return new GeneratorResult([clearanceRequest]);
}
}
public class CrNoMatchScenarioGenerator(ILogger<CrNoMatchScenarioGenerator> logger) : ScenarioGenerator
{
public override GeneratorResult Generate(int scenario, int item, DateTime entryDate, ScenarioConfig config)
{
var clearanceRequest = NoMatchExtensions
.SimpleClearanceRequest(scenario, item, entryDate, config)
.WithRandomItems(10, 100)
.ValidateAndBuild();
logger.LogInformation("Created {EntryReference}", clearanceRequest.Header!.EntryReference);
var alvsDecision = clearanceRequest
.GetDecisionBuilder()
.ValidateAndBuild();
logger.LogInformation("Created {EntryReference}", alvsDecision.Header!.EntryReference);
return new GeneratorResult([clearanceRequest, alvsDecision]);
}
}
public class CrNoMatchNonContiguousDecisionsScenarioGenerator(ILogger<CrNoMatchNonContiguousDecisionsScenarioGenerator> logger) : ScenarioGenerator
{
public override GeneratorResult Generate(int scenario, int item, DateTime entryDate, ScenarioConfig config)
{
var clearanceRequest = NoMatchExtensions
.CompleteSimpleClearanceRequest(scenario, item, entryDate, config);
logger.LogInformation("Created {EntryReference}", clearanceRequest.Header!.EntryReference);
var alvsDecisionBuilder = clearanceRequest
.GetDecisionBuilder()
.WithDecisionVersionNumber(1);
var alvsDecision = alvsDecisionBuilder
.ValidateAndBuild();
var alvsDecision2 = alvsDecisionBuilder
.Clone()
.WithDecisionVersionNumber(3)
.ValidateAndBuild();
logger.LogInformation("Created {EntryReference}", alvsDecision.Header!.EntryReference);
return new GeneratorResult([clearanceRequest, alvsDecision, alvsDecision2]);
}
}
public class CrDecisionWithoutV1ScenarioGenerator(ILogger<CrDecisionWithoutV1ScenarioGenerator> logger) : ScenarioGenerator
{
public override GeneratorResult Generate(int scenario, int item, DateTime entryDate, ScenarioConfig config)
{
var clearanceRequest = NoMatchExtensions
.CompleteSimpleClearanceRequest(scenario, item, entryDate, config);
logger.LogInformation("Created {EntryReference}", clearanceRequest.Header!.EntryReference);
var alvsDecision = clearanceRequest
.GetDecisionBuilder()
.WithDecisionVersionNumber(2)
.Build();
logger.LogInformation("Created {EntryReference}", alvsDecision.Header!.EntryReference);
return new GeneratorResult([clearanceRequest, alvsDecision]);
}
}