Skip to content

Commit a83de89

Browse files
committed
ReserveCabinPersonnel -> Purser, CabinPersonnel -> CabinCrewMembers
1 parent 8c2a7b4 commit a83de89

File tree

6 files changed

+229
-184
lines changed

6 files changed

+229
-184
lines changed

test/OpenApiClientTests/LegacyClient/RequestTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,12 @@ public async Task Getting_secondary_resources_produces_expected_request()
255255
IOpenApiClient apiOpenApiClient = new OpenApiClient(wrapper.HttpClient);
256256

257257
// Act
258-
_ = await ApiResponse.TranslateAsync(async () => await apiOpenApiClient.GetFlightCabinPersonnelAsync(flightId));
258+
_ = await ApiResponse.TranslateAsync(async () => await apiOpenApiClient.GetFlightCabinCrewMembersAsync(flightId));
259259

260260
// Assert
261261
wrapper.Request.Headers.GetValue(HeaderNames.Accept).Should().Be(HeaderConstants.MediaType);
262262
wrapper.Request.Method.Should().Be(HttpMethod.Get);
263-
wrapper.Request.RequestUri.Should().Be(HostPrefix + $"flights/{flightId}/cabin-personnel");
263+
wrapper.Request.RequestUri.Should().Be(HostPrefix + $"flights/{flightId}/cabin-crew-members");
264264
wrapper.RequestBody.Should().BeNull();
265265
}
266266

@@ -329,12 +329,12 @@ public async Task Getting_ToMany_relationship_produces_expected_request()
329329
IOpenApiClient apiOpenApiClient = new OpenApiClient(wrapper.HttpClient);
330330

331331
// Act
332-
_ = await ApiResponse.TranslateAsync(async () => await apiOpenApiClient.GetFlightCabinPersonnelRelationshipAsync(flightId));
332+
_ = await ApiResponse.TranslateAsync(async () => await apiOpenApiClient.GetFlightCabinCrewMembersRelationshipAsync(flightId));
333333

334334
// Assert
335335
wrapper.Request.Headers.GetValue(HeaderNames.Accept).Should().Be(HeaderConstants.MediaType);
336336
wrapper.Request.Method.Should().Be(HttpMethod.Get);
337-
wrapper.Request.RequestUri.Should().Be(HostPrefix + $"flights/{flightId}/relationships/cabin-personnel");
337+
wrapper.Request.RequestUri.Should().Be(HostPrefix + $"flights/{flightId}/relationships/cabin-crew-members");
338338
wrapper.RequestBody.Should().BeNull();
339339
}
340340

@@ -365,11 +365,11 @@ public async Task Posting_ToMany_relationship_produces_expected_request()
365365
};
366366

367367
// Act
368-
await apiOpenApiClient.PostFlightCabinPersonnelRelationshipAsync(flightId, requestDocument);
368+
await apiOpenApiClient.PostFlightCabinCrewMembersRelationshipAsync(flightId, requestDocument);
369369

370370
// Assert
371371
wrapper.Request.Method.Should().Be(HttpMethod.Post);
372-
wrapper.Request.RequestUri.Should().Be(HostPrefix + $"flights/{flightId}/relationships/cabin-personnel");
372+
wrapper.Request.RequestUri.Should().Be(HostPrefix + $"flights/{flightId}/relationships/cabin-crew-members");
373373
wrapper.Request.Content.Should().NotBeNull();
374374
wrapper.Request.Content!.Headers.ContentType.Should().NotBeNull();
375375
wrapper.Request.Content!.Headers.ContentType!.ToString().Should().Be(HeaderConstants.MediaType);
@@ -415,11 +415,11 @@ public async Task Patching_ToMany_relationship_produces_expected_request()
415415
};
416416

417417
// Act
418-
await apiOpenApiClient.PatchFlightCabinPersonnelRelationshipAsync(flightId, requestDocument);
418+
await apiOpenApiClient.PatchFlightCabinCrewMembersRelationshipAsync(flightId, requestDocument);
419419

420420
// Assert
421421
wrapper.Request.Method.Should().Be(HttpMethod.Patch);
422-
wrapper.Request.RequestUri.Should().Be(HostPrefix + $"flights/{flightId}/relationships/cabin-personnel");
422+
wrapper.Request.RequestUri.Should().Be(HostPrefix + $"flights/{flightId}/relationships/cabin-crew-members");
423423
wrapper.Request.Content.Should().NotBeNull();
424424
wrapper.Request.Content!.Headers.ContentType.Should().NotBeNull();
425425
wrapper.Request.Content!.Headers.ContentType!.ToString().Should().Be(HeaderConstants.MediaType);
@@ -465,11 +465,11 @@ public async Task Deleting_ToMany_relationship_produces_expected_request()
465465
};
466466

467467
// Act
468-
await apiOpenApiClient.DeleteFlightCabinPersonnelRelationshipAsync(flightId, requestDocument);
468+
await apiOpenApiClient.DeleteFlightCabinCrewMembersRelationshipAsync(flightId, requestDocument);
469469

470470
// Assert
471471
wrapper.Request.Method.Should().Be(HttpMethod.Delete);
472-
wrapper.Request.RequestUri.Should().Be(HostPrefix + $"flights/{flightId}/relationships/cabin-personnel");
472+
wrapper.Request.RequestUri.Should().Be(HostPrefix + $"flights/{flightId}/relationships/cabin-crew-members");
473473
wrapper.Request.Content.Should().NotBeNull();
474474
wrapper.Request.Content!.Headers.ContentType.Should().NotBeNull();
475475
wrapper.Request.Content!.Headers.ContentType!.ToString().Should().Be(HeaderConstants.MediaType);

test/OpenApiClientTests/LegacyClient/ResponseTests.cs

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public async Task Getting_resource_collection_translates_response()
2828
const string documentMetaValue = "1";
2929
const string flightMetaValue = "https://api.jsonapi.net/docs/#get-flights";
3030
const string operatingAirplaneMetaValue = "https://jsonapi.net/api/docs/#get-flight-operating-airplane";
31-
const string cabinPersonnelMetaValue = "https://jsonapi.net/api/docs/#get-flight-cabin-personnel";
32-
const string reserveCabinPersonnelMetaValue = "https://jsonapi.net/api/docs/#get-flight-backup-cabin-personnel";
31+
const string cabinPersonnelMetaValue = "https://jsonapi.net/api/docs/#get-flight-cabin-crew-members";
32+
const string purserMetaValue = "https://jsonapi.net/api/docs/#get-flight-purser";
3333
const string topLevelLink = HostPrefix + "flights";
3434
const string flightResourceLink = topLevelLink + "/" + flightId;
3535

@@ -68,22 +68,22 @@ public async Task Getting_resource_collection_translates_response()
6868
""docs"": """ + operatingAirplaneMetaValue + @"""
6969
}
7070
},
71-
""cabin-personnel"": {
71+
""cabin-crew-members"": {
7272
""links"": {
73-
""self"": """ + flightResourceLink + @"/relationships/cabin-personnel"",
74-
""related"": """ + flightResourceLink + @"/cabin-personnel""
73+
""self"": """ + flightResourceLink + @"/relationships/cabin-crew-members"",
74+
""related"": """ + flightResourceLink + @"/cabin-crew-members""
7575
},
7676
""meta"": {
7777
""docs"": """ + cabinPersonnelMetaValue + @"""
7878
}
7979
},
80-
""backup-cabin-personnel"": {
80+
""purser"": {
8181
""links"": {
82-
""self"": """ + flightResourceLink + @"/relationships/backup-cabin-personnel"",
83-
""related"": """ + flightResourceLink + @"/backup-cabin-personnel""
82+
""self"": """ + flightResourceLink + @"/relationships/purser"",
83+
""related"": """ + flightResourceLink + @"/purser""
8484
},
8585
""meta"": {
86-
""docs"": """ + reserveCabinPersonnelMetaValue + @"""
86+
""docs"": """ + purserMetaValue + @"""
8787
}
8888
}
8989
},
@@ -134,17 +134,17 @@ public async Task Getting_resource_collection_translates_response()
134134
flight.Relationships.OperatingAirplane.Meta.Should().HaveCount(1);
135135
flight.Relationships.OperatingAirplane.Meta["docs"].Should().Be(operatingAirplaneMetaValue);
136136

137-
flight.Relationships.CabinPersonnel.Data.Should().BeNull();
138-
flight.Relationships.CabinPersonnel.Links.Self.Should().Be(flightResourceLink + "/relationships/cabin-personnel");
139-
flight.Relationships.CabinPersonnel.Links.Related.Should().Be(flightResourceLink + "/cabin-personnel");
140-
flight.Relationships.CabinPersonnel.Meta.Should().HaveCount(1);
141-
flight.Relationships.CabinPersonnel.Meta["docs"].Should().Be(cabinPersonnelMetaValue);
142-
143-
flight.Relationships.BackupCabinPersonnel.Data.Should().BeNull();
144-
flight.Relationships.BackupCabinPersonnel.Links.Self.Should().Be(flightResourceLink + "/relationships/backup-cabin-personnel");
145-
flight.Relationships.BackupCabinPersonnel.Links.Related.Should().Be(flightResourceLink + "/backup-cabin-personnel");
146-
flight.Relationships.BackupCabinPersonnel.Meta.Should().HaveCount(1);
147-
flight.Relationships.BackupCabinPersonnel.Meta["docs"].Should().Be(reserveCabinPersonnelMetaValue);
137+
flight.Relationships.CabinCrewMembers.Data.Should().BeNull();
138+
flight.Relationships.CabinCrewMembers.Links.Self.Should().Be(flightResourceLink + "/relationships/cabin-crew-members");
139+
flight.Relationships.CabinCrewMembers.Links.Related.Should().Be(flightResourceLink + "/cabin-crew-members");
140+
flight.Relationships.CabinCrewMembers.Meta.Should().HaveCount(1);
141+
flight.Relationships.CabinCrewMembers.Meta["docs"].Should().Be(cabinPersonnelMetaValue);
142+
143+
flight.Relationships.Purser.Data.Should().BeNull();
144+
flight.Relationships.Purser.Links.Self.Should().Be(flightResourceLink + "/relationships/purser");
145+
flight.Relationships.Purser.Links.Related.Should().Be(flightResourceLink + "/purser");
146+
flight.Relationships.Purser.Meta.Should().HaveCount(1);
147+
flight.Relationships.Purser.Meta["docs"].Should().Be(purserMetaValue);
148148
}
149149

150150
[Fact]
@@ -230,7 +230,7 @@ public async Task Posting_resource_translates_response()
230230

231231
const string responseBody = @"{
232232
""links"": {
233-
""self"": """ + HostPrefix + @"flights/" + flightId + @"&fields[flights]&include=operating-airplane,cabin-personnel,backup-cabin-personnel""
233+
""self"": """ + HostPrefix + @"flights/" + flightId + @"&fields[flights]&include=operating-airplane,cabin-crew-members,purser""
234234
},
235235
""data"": {
236236
""type"": ""flights"",
@@ -243,10 +243,10 @@ public async Task Posting_resource_translates_response()
243243
},
244244
""data"": null
245245
},
246-
""cabin-personnel"": {
246+
""cabin-crew-members"": {
247247
""links"": {
248-
""self"": """ + HostPrefix + @"flights/" + flightId + @"/relationships/cabin-personnel"",
249-
""related"": """ + HostPrefix + @"flights/" + flightId + @"/cabin-personnel""
248+
""self"": """ + HostPrefix + @"flights/" + flightId + @"/relationships/cabin-crew-members"",
249+
""related"": """ + HostPrefix + @"flights/" + flightId + @"/cabin-crew-members""
250250
},
251251
""data"": [
252252
{
@@ -255,16 +255,16 @@ public async Task Posting_resource_translates_response()
255255
}
256256
],
257257
},
258-
""backup-cabin-personnel"": {
258+
""purser"": {
259259
""links"": {
260-
""self"": """ + HostPrefix + @"flights/" + flightId + @"/relationships/backup-cabin-personnel"",
261-
""related"": """ + HostPrefix + @"flights/" + flightId + @"/backup-cabin-personnel""
260+
""self"": """ + HostPrefix + @"flights/" + flightId + @"/relationships/purser"",
261+
""related"": """ + HostPrefix + @"flights/" + flightId + @"/purser""
262262
},
263-
""data"": [ ]
263+
""data"": null
264264
}
265265
},
266266
""links"": {
267-
""self"": """ + HostPrefix + @"flights/" + flightId + @"&fields[flights]&include=operating-airplane,cabin-personnel,backup-cabin-personnel""
267+
""self"": """ + HostPrefix + @"flights/" + flightId + @"&fields[flights]&include=operating-airplane,cabin-crew-members,purser""
268268
}
269269
}
270270
}";
@@ -295,10 +295,10 @@ public async Task Posting_resource_translates_response()
295295
// Assert
296296
document.Data.Attributes.Should().BeNull();
297297
document.Data.Relationships.OperatingAirplane.Data.Should().BeNull();
298-
document.Data.Relationships.CabinPersonnel.Data.Should().HaveCount(1);
299-
document.Data.Relationships.CabinPersonnel.Data.First().Id.Should().Be(flightAttendantId);
300-
document.Data.Relationships.CabinPersonnel.Data.First().Type.Should().Be(FlightAttendantsResourceType.FlightAttendants);
301-
document.Data.Relationships.BackupCabinPersonnel.Data.Should().BeEmpty();
298+
document.Data.Relationships.CabinCrewMembers.Data.Should().HaveCount(1);
299+
document.Data.Relationships.CabinCrewMembers.Data.First().Id.Should().Be(flightAttendantId);
300+
document.Data.Relationships.CabinCrewMembers.Data.First().Type.Should().Be(FlightAttendantsResourceType.FlightAttendants);
301+
document.Data.Relationships.Purser.Data.Should().BeNull();
302302
}
303303

304304
[Fact]
@@ -315,7 +315,7 @@ public async Task Patching_resource_with_side_effects_translates_response()
315315
""type"": ""flights"",
316316
""id"": """ + flightId + @""",
317317
""links"": {
318-
""self"": """ + HostPrefix + @"flights/" + flightId + @"&fields[flights]&include=operating-airplane,cabin-personnel,backup-cabin-personnel""
318+
""self"": """ + HostPrefix + @"flights/" + flightId + @"&fields[flights]&include=operating-airplane,cabin-crew-members,purser""
319319
}
320320
}
321321
}";
@@ -409,8 +409,8 @@ public async Task Getting_secondary_resources_translates_response()
409409

410410
const string responseBody = @"{
411411
""links"": {
412-
""self"": """ + HostPrefix + @"flights/" + flightId + @"/cabin-personnel"",
413-
""first"": """ + HostPrefix + @"flights/" + flightId + @"/cabin-personnel""
412+
""self"": """ + HostPrefix + @"flights/" + flightId + @"/cabin-crew-members"",
413+
""first"": """ + HostPrefix + @"flights/" + flightId + @"/cabin-crew-members""
414414
},
415415
""data"": [ ]
416416
}";
@@ -419,7 +419,7 @@ public async Task Getting_secondary_resources_translates_response()
419419
IOpenApiClient openApiClient = new OpenApiClient(wrapper.HttpClient);
420420

421421
// Act
422-
FlightAttendantCollectionResponseDocument document = await openApiClient.GetFlightCabinPersonnelAsync(flightId);
422+
FlightAttendantCollectionResponseDocument document = await openApiClient.GetFlightCabinCrewMembersAsync(flightId);
423423

424424
// Assert
425425
document.Data.Should().BeEmpty();
@@ -483,9 +483,9 @@ public async Task Getting_ToMany_relationship_translates_response()
483483

484484
const string responseBody = @"{
485485
""links"": {
486-
""self"": """ + HostPrefix + @"flights/" + flightId + @"/relationships/cabin-personnel"",
487-
""related"": """ + HostPrefix + @"flights/" + flightId + @"/relationships/cabin-personnel"",
488-
""first"": """ + HostPrefix + @"flights/" + flightId + @"/relationships/cabin-personnel""
486+
""self"": """ + HostPrefix + @"flights/" + flightId + @"/relationships/cabin-crew-members"",
487+
""related"": """ + HostPrefix + @"flights/" + flightId + @"/relationships/cabin-crew-members"",
488+
""first"": """ + HostPrefix + @"flights/" + flightId + @"/relationships/cabin-crew-members""
489489
},
490490
""data"": [{
491491
""type"": ""flight-attendants"",
@@ -501,7 +501,7 @@ public async Task Getting_ToMany_relationship_translates_response()
501501
IOpenApiClient openApiClient = new OpenApiClient(wrapper.HttpClient);
502502

503503
// Act
504-
FlightAttendantIdentifierCollectionResponseDocument document = await openApiClient.GetFlightCabinPersonnelRelationshipAsync(flightId);
504+
FlightAttendantIdentifierCollectionResponseDocument document = await openApiClient.GetFlightCabinCrewMembersRelationshipAsync(flightId);
505505

506506
// Assert
507507
document.Data.Should().HaveCount(2);
@@ -519,7 +519,7 @@ public async Task Posting_ToMany_relationship_produces_empty_response()
519519
IOpenApiClient openApiClient = new OpenApiClient(wrapper.HttpClient);
520520

521521
// Act
522-
Func<Task> action = async () => await openApiClient.PostFlightCabinPersonnelRelationshipAsync("ZvuH1", new ToManyFlightAttendantRequestData
522+
Func<Task> action = async () => await openApiClient.PostFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantRequestData
523523
{
524524
Data = new List<FlightAttendantIdentifier>
525525
{
@@ -548,7 +548,7 @@ public async Task Patching_ToMany_relationship_produces_empty_response()
548548
IOpenApiClient openApiClient = new OpenApiClient(wrapper.HttpClient);
549549

550550
// Act
551-
Func<Task> action = async () => await openApiClient.PatchFlightCabinPersonnelRelationshipAsync("ZvuH1", new ToManyFlightAttendantRequestData
551+
Func<Task> action = async () => await openApiClient.PatchFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantRequestData
552552
{
553553
Data = new List<FlightAttendantIdentifier>
554554
{
@@ -577,7 +577,7 @@ public async Task Deleting_ToMany_relationship_produces_empty_response()
577577
IOpenApiClient openApiClient = new OpenApiClient(wrapper.HttpClient);
578578

579579
// Act
580-
Func<Task> action = async () => await openApiClient.DeleteFlightCabinPersonnelRelationshipAsync("ZvuH1", new ToManyFlightAttendantRequestData
580+
Func<Task> action = async () => await openApiClient.DeleteFlightCabinCrewMembersRelationshipAsync("ZvuH1", new ToManyFlightAttendantRequestData
581581
{
582582
Data = new List<FlightAttendantIdentifier>
583583
{

test/OpenApiTests/LegacyOpenApiIntegration/Flight.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public sealed class Flight : Identifiable<string>
3030
public DateTime? ArrivesAt { get; set; }
3131

3232
[HasMany]
33-
public ISet<FlightAttendant> CabinPersonnel { get; set; }
33+
public ISet<FlightAttendant> CabinCrewMembers { get; set; }
3434

3535
[HasOne]
3636
public Airplane OperatingAirplane { get; set; }
@@ -39,7 +39,7 @@ public sealed class Flight : Identifiable<string>
3939
[NotMapped]
4040
public ICollection<string> ServicesOnBoard { get; set; }
4141

42-
[HasMany]
43-
public ICollection<FlightAttendant> BackupCabinPersonnel { get; set; }
42+
[HasOne]
43+
public FlightAttendant Purser { get; set; }
4444
}
4545
}

test/OpenApiTests/LegacyOpenApiIntegration/FlightAttendant.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ public sealed class FlightAttendant : Identifiable<long>
4242
public ISet<Flight> ScheduledForFlights { get; set; }
4343

4444
[HasMany]
45-
public ISet<Flight> StandbyForFlights { get; set; }
45+
public ISet<Flight> PurserOnFlights { get; set; }
4646
}
4747
}

test/OpenApiTests/LegacyOpenApiIntegration/LegacyIntegrationDbContext.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public LegacyIntegrationDbContext(DbContextOptions<LegacyIntegrationDbContext> o
2121
protected override void OnModelCreating(ModelBuilder builder)
2222
{
2323
builder.Entity<Flight>()
24-
.HasMany(flight => flight.CabinPersonnel)
24+
.HasMany(flight => flight.CabinCrewMembers)
2525
.WithMany(flightAttendant => flightAttendant.ScheduledForFlights);
2626

2727
builder.Entity<Flight>()
28-
.HasMany(flight => flight.BackupCabinPersonnel)
29-
.WithMany(flightAttendant => flightAttendant.StandbyForFlights);
28+
.HasOne(flight => flight.Purser)
29+
.WithMany(flightAttendant => flightAttendant.PurserOnFlights);
3030
}
3131
}
3232
}

0 commit comments

Comments
 (0)