Skip to content

Commit

Permalink
Rename deck to inspection area
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Dec 18, 2024
1 parent 358ee8c commit 442e0e4
Show file tree
Hide file tree
Showing 69 changed files with 3,821 additions and 849 deletions.
2 changes: 1 addition & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ The access matrix looks like this:
| | **Read Only** | **User** | **Admin** |
| -------------------------- | ------------- | -------- | --------- |
| Area | Read | Read | CRUD |
| Deck | Read | Read | CRUD |
| InspectionArea | Read | Read | CRUD |
| Plant | Read | Read | CRUD |
| Installation | Read | Read | CRUD |
| MissionLoader | Read | Read | CRUD |
Expand Down
44 changes: 22 additions & 22 deletions backend/api.test/Client/AreaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,20 @@ public async Task AreaTest()
Name = testPlant
};

string testDeck = "testDeckAreaTest";
var deckQuery = new CreateDeckQuery
string testInspectionArea = "testInspectionAreaAreaTest";
var inspectionAreaQuery = new CreateInspectionAreaQuery
{
InstallationCode = testInstallation,
PlantCode = testPlant,
Name = testDeck
Name = testInspectionArea
};

string testArea = "testAreaAreaTest";
var areaQuery = new CreateAreaQuery
{
InstallationCode = testInstallation,
PlantCode = testPlant,
DeckName = testDeck,
InspectionAreaName = testInspectionArea,
AreaName = testArea,
DefaultLocalizationPose = testPose
};
Expand All @@ -112,8 +112,8 @@ public async Task AreaTest()
"application/json"
);

var deckContent = new StringContent(
JsonSerializer.Serialize(deckQuery),
var inspectionAreaContent = new StringContent(
JsonSerializer.Serialize(inspectionAreaQuery),
null,
"application/json"
);
Expand All @@ -129,15 +129,15 @@ public async Task AreaTest()
var installationResponse = await _client.PostAsync(installationUrl, installationContent);
string plantUrl = "/plants";
var plantResponse = await _client.PostAsync(plantUrl, plantContent);
string deckUrl = "/decks";
var deckResponse = await _client.PostAsync(deckUrl, deckContent);
string inspectionAreaUrl = "/inspectionAreas";
var inspectionAreaResponse = await _client.PostAsync(inspectionAreaUrl, inspectionAreaContent);
string areaUrl = "/areas";
var areaResponse = await _client.PostAsync(areaUrl, areaContent);

// Assert
Assert.True(installationResponse.IsSuccessStatusCode);
Assert.True(plantResponse.IsSuccessStatusCode);
Assert.True(deckResponse.IsSuccessStatusCode);
Assert.True(inspectionAreaResponse.IsSuccessStatusCode);
Assert.True(areaResponse.IsSuccessStatusCode);
var area = await areaResponse.Content.ReadFromJsonAsync<AreaResponse>(_serializerOptions);
Assert.NotNull(area);
Expand All @@ -149,7 +149,7 @@ public async Task MissionIsCreatedInInspectionArea()
// Arrange - Initialise area
var installation = await _databaseUtilities.ReadOrNewInstallation();
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);
var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode);
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode);

// Arrange - Robot
var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation);
Expand Down Expand Up @@ -178,7 +178,7 @@ public async Task MissionIsCreatedInInspectionArea()
RobotId = robotId,
DesiredStartTime = DateTime.UtcNow,
InstallationCode = installation.InstallationCode,
InspectionAreaName = deck.Name,
InspectionAreaName = inspectionArea.Name,
Name = testMissionName,
Tasks = tasks
};
Expand All @@ -197,8 +197,8 @@ public async Task MissionIsCreatedInInspectionArea()
var mission = await missionResponse.Content.ReadFromJsonAsync<MissionRun>(_serializerOptions);
Assert.NotNull(mission);
Assert.NotNull(mission.MissionId);
string inspectionAreaUrl = "/decks";
var inspectionareaMissionsResponse = await _client.GetAsync(inspectionAreaUrl + $"/{deck.Id}/mission-definitions");
string inspectionAreaUrl = "/inspectionAreas";
var inspectionareaMissionsResponse = await _client.GetAsync(inspectionAreaUrl + $"/{inspectionArea.Id}/mission-definitions");

// Assert
Assert.True(inspectionareaMissionsResponse.IsSuccessStatusCode);
Expand Down Expand Up @@ -228,16 +228,16 @@ public async Task EmergencyDockTest()
}

[Fact]
public async Task UpdateDefaultLocalizationPoseOnDeck()
public async Task UpdateDefaultLocalizationPoseOnInspectionArea()
{
// Arrange
var installation = await _databaseUtilities.ReadOrNewInstallation();
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);
var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode);
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode);

string deckId = deck.Id;
string inspectionAreaId = inspectionArea.Id;

string url = $"/decks/{deckId}/update-default-localization-pose";
string url = $"/inspectionAreas/{inspectionAreaId}/update-default-localization-pose";
var query = new CreateDefaultLocalizationPose
{
Pose = new Pose
Expand Down Expand Up @@ -266,13 +266,13 @@ public async Task UpdateDefaultLocalizationPoseOnDeck()
// Act
var putResponse = await _client.PutAsync(url, content);
Assert.True(putResponse.IsSuccessStatusCode);
var putDeck = await putResponse.Content.ReadFromJsonAsync<DeckResponse>(_serializerOptions);
var putInspectionArea = await putResponse.Content.ReadFromJsonAsync<InspectionAreaResponse>(_serializerOptions);

// Assert
Assert.NotNull(putDeck);
Assert.NotNull(putDeck.DefaultLocalizationPose);
Assert.True(putDeck.DefaultLocalizationPose.Position.Z.Equals(query.Pose.Position.Z));
Assert.True(putDeck.DefaultLocalizationPose.Orientation.W.Equals(query.Pose.Orientation.W));
Assert.NotNull(putInspectionArea);
Assert.NotNull(putInspectionArea.DefaultLocalizationPose);
Assert.True(putInspectionArea.DefaultLocalizationPose.Position.Z.Equals(query.Pose.Position.Z));
Assert.True(putInspectionArea.DefaultLocalizationPose.Orientation.W.Equals(query.Pose.Orientation.W));
}
}
}
44 changes: 22 additions & 22 deletions backend/api.test/Client/MissionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ public async Task AddNonDuplicateAreasToDb()
// Arrange
var installation = await _databaseUtilities.ReadOrNewInstallation();
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);
var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode);
var _ = await _databaseUtilities.ReadOrNewArea(installation.InstallationCode, plant.PlantCode, deck.Name);
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode);
var _ = await _databaseUtilities.ReadOrNewArea(installation.InstallationCode, plant.PlantCode, inspectionArea.Name);

var testPose = new Pose
{
Expand All @@ -182,7 +182,7 @@ public async Task AddNonDuplicateAreasToDb()
{
InstallationCode = installation.InstallationCode,
PlantCode = plant.PlantCode,
DeckName = deck.Name,
InspectionAreaName = inspectionArea.Name,
AreaName = "AddNonDuplicateAreasToDb_Area",
DefaultLocalizationPose = testPose
};
Expand All @@ -206,8 +206,8 @@ public async Task AddDuplicateAreasToDb_Fails()
// Arrange
var installation = await _databaseUtilities.ReadOrNewInstallation();
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);
var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode);
var area = await _databaseUtilities.ReadOrNewArea(installation.InstallationCode, plant.PlantCode, deck.Name);
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode);
var area = await _databaseUtilities.ReadOrNewArea(installation.InstallationCode, plant.PlantCode, inspectionArea.Name);

var testPose = new Pose
{
Expand All @@ -229,7 +229,7 @@ public async Task AddDuplicateAreasToDb_Fails()
{
InstallationCode = installation.InstallationCode,
PlantCode = plant.PlantCode,
DeckName = deck.Name,
InspectionAreaName = inspectionArea.Name,
AreaName = area.Name,
DefaultLocalizationPose = testPose
};
Expand Down Expand Up @@ -267,7 +267,7 @@ public async Task ScheduleDuplicateCustomMissionDefinitions()
// Arrange
var installation = await _databaseUtilities.ReadOrNewInstallation();
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);
var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode);
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode);

string testMissionName = "testMissionScheduleDuplicateCustomMissionDefinitions";

Expand All @@ -280,7 +280,7 @@ public async Task ScheduleDuplicateCustomMissionDefinitions()
{
RobotId = robotId,
InstallationCode = installation.InstallationCode,
InspectionAreaName = deck.Name,
InspectionAreaName = inspectionArea.Name,
DesiredStartTime = DateTime.SpecifyKind(new DateTime(3050, 1, 1), DateTimeKind.Utc),
InspectionFrequency = new TimeSpan(14, 0, 0, 0),
Name = testMissionName,
Expand Down Expand Up @@ -342,7 +342,7 @@ public async Task GetNextRun()
// Arrange - Initialise area
var installation = await _databaseUtilities.ReadOrNewInstallation();
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);
var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode);
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode);

// Arrange - Robot
var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation);
Expand All @@ -354,7 +354,7 @@ public async Task GetNextRun()
{
RobotId = robotId,
InstallationCode = installation.InstallationCode,
InspectionAreaName = deck.Name,
InspectionAreaName = inspectionArea.Name,
DesiredStartTime = DateTime.SpecifyKind(new DateTime(3050, 1, 1), DateTimeKind.Utc),
InspectionFrequency = new TimeSpan(14, 0, 0, 0),
Name = testMissionName,
Expand Down Expand Up @@ -448,8 +448,8 @@ public async Task ScheduleDuplicatMissionDefinitions()
// Arrange - Initialise area
var installation = await _databaseUtilities.ReadOrNewInstallation();
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);
var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode);
var area = await _databaseUtilities.ReadOrNewArea(installation.InstallationCode, plant.PlantCode, deck.Name);
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode);
var area = await _databaseUtilities.ReadOrNewArea(installation.InstallationCode, plant.PlantCode, inspectionArea.Name);

// Arrange - Robot
var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation);
Expand Down Expand Up @@ -499,7 +499,7 @@ public async Task MissionDoesNotStartIfRobotIsNotInSameInstallationAsMission()
// Arrange - Initialise area
var installation = await _databaseUtilities.ReadOrNewInstallation();
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);
var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode);
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode);

string testMissionName = "testMissionDoesNotStartIfRobotIsNotInSameInstallationAsMission";

Expand All @@ -516,7 +516,7 @@ public async Task MissionDoesNotStartIfRobotIsNotInSameInstallationAsMission()
{
RobotId = robotId,
InstallationCode = installation.InstallationCode,
InspectionAreaName = deck.Name,
InspectionAreaName = inspectionArea.Name,
DesiredStartTime = DateTime.SpecifyKind(new DateTime(3050, 1, 1), DateTimeKind.Utc),
InspectionFrequency = new TimeSpan(14, 0, 0, 0),
Name = testMissionName,
Expand Down Expand Up @@ -556,30 +556,30 @@ public async Task MissionDoesNotStartIfRobotIsNotInSameInstallationAsMission()
}

[Fact]
public async Task MissionFailsIfRobotIsNotInSameDeckAsMission()
public async Task MissionFailsIfRobotIsNotInSameInspectionAreaAsMission()
{
// Arrange - Initialise area
var installation = await _databaseUtilities.ReadOrNewInstallation();
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);

string deckName1 = "deckMissionFailsIfRobotIsNotInSameDeckAsMission1";
var deck1 = await _databaseUtilities.NewDeck(installation.InstallationCode, plant.PlantCode, deckName1);
string inspectionAreaName1 = "inspectionAreaMissionFailsIfRobotIsNotInSameInspectionAreaAsMission1";
var inspectionArea1 = await _databaseUtilities.NewInspectionArea(installation.InstallationCode, plant.PlantCode, inspectionAreaName1);

string deckName2 = "deckMissionFailsIfRobotIsNotInSameDeckAsMission2";
var deck2 = await _databaseUtilities.NewDeck(installation.InstallationCode, plant.PlantCode, deckName2);
string inspectionAreaName2 = "inspectionAreaMissionFailsIfRobotIsNotInSameInspectionAreaAsMission2";
var inspectionArea2 = await _databaseUtilities.NewInspectionArea(installation.InstallationCode, plant.PlantCode, inspectionAreaName2);

string testMissionName = "testMissionFailsIfRobotIsNotInSameDeckAsMission";
string testMissionName = "testMissionFailsIfRobotIsNotInSameInspectionAreaAsMission";

// Arrange - Robot
var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, deck1);
var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, inspectionArea1);
string robotId = robot.Id;

// Arrange - Mission Run Query
var query = new CustomMissionQuery
{
RobotId = robotId,
InstallationCode = installation.InstallationCode,
InspectionAreaName = deck2.Name,
InspectionAreaName = inspectionArea2.Name,
DesiredStartTime = DateTime.SpecifyKind(new DateTime(3050, 1, 1), DateTimeKind.Utc),
InspectionFrequency = new TimeSpan(14, 0, 0, 0),
Name = testMissionName,
Expand Down
6 changes: 3 additions & 3 deletions backend/api.test/Client/RobotTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public async Task RobotIsNotCreatedWithAreaNotInInstallation()

var wrongInstallation = await _databaseUtilities.NewInstallation("wrongInstallation");
var wrongPlant = await _databaseUtilities.ReadOrNewPlant(wrongInstallation.InstallationCode);
var wrongDeck = await _databaseUtilities.ReadOrNewDeck(wrongInstallation.InstallationCode, wrongPlant.PlantCode);
var wrongInspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(wrongInstallation.InstallationCode, wrongPlant.PlantCode);

// Arrange - Create robot
var robotQuery = new CreateRobotQuery
Expand All @@ -108,7 +108,7 @@ public async Task RobotIsNotCreatedWithAreaNotInInstallation()
Host = "localhost",
Port = 3000,
CurrentInstallationCode = installation.InstallationCode,
CurrentInspectionAreaName = wrongDeck.Name,
CurrentInspectionAreaName = wrongInspectionArea.Name,
};

string robotUrl = "/robots";
Expand All @@ -124,7 +124,7 @@ public async Task RobotIsNotCreatedWithAreaNotInInstallation()
}
catch (DbUpdateException ex)
{
Assert.True(ex.Message == $"Could not create new robot in database as inspection area '{wrongDeck.Name}' does not exist in installation {installation.InstallationCode}");
Assert.True(ex.Message == $"Could not create new robot in database as inspection area '{wrongInspectionArea.Name}' does not exist in installation {installation.InstallationCode}");
}
}
}
Expand Down
Loading

0 comments on commit 442e0e4

Please sign in to comment.