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 23, 2024
1 parent f9fba4d commit ac2b978
Show file tree
Hide file tree
Showing 69 changed files with 4,068 additions and 890 deletions.
2 changes: 1 addition & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,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
56 changes: 32 additions & 24 deletions backend/api.test/Client/AreaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,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 @@ -113,8 +113,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 @@ -133,15 +133,18 @@ public async Task AreaTest()
);
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
Expand All @@ -155,7 +158,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(
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(
installation.InstallationCode,
plant.PlantCode
);
Expand Down Expand Up @@ -187,7 +190,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 @@ -208,9 +211,9 @@ public async Task MissionIsCreatedInInspectionArea()
);
Assert.NotNull(mission);
Assert.NotNull(mission.MissionId);
string inspectionAreaUrl = "/decks";
string inspectionAreaUrl = "/inspectionAreas";
var inspectionareaMissionsResponse = await _client.GetAsync(
inspectionAreaUrl + $"/{deck.Id}/mission-definitions"
inspectionAreaUrl + $"/{inspectionArea.Id}/mission-definitions"
);

// Assert
Expand Down Expand Up @@ -245,19 +248,19 @@ 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(
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 @@ -286,16 +289,21 @@ 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.NotNull(putInspectionArea);
Assert.NotNull(putInspectionArea.DefaultLocalizationPose);
Assert.True(
putInspectionArea.DefaultLocalizationPose.Position.Z.Equals(query.Pose.Position.Z)
);
Assert.True(
putDeck.DefaultLocalizationPose.Orientation.W.Equals(query.Pose.Orientation.W)
putInspectionArea.DefaultLocalizationPose.Orientation.W.Equals(
query.Pose.Orientation.W
)
);
}
}
Expand Down
50 changes: 26 additions & 24 deletions backend/api.test/Client/MissionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ public async Task AddNonDuplicateAreasToDb()
// Arrange
var installation = await _databaseUtilities.ReadOrNewInstallation();
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);
var deck = await _databaseUtilities.ReadOrNewDeck(
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(
installation.InstallationCode,
plant.PlantCode
);
var _ = await _databaseUtilities.ReadOrNewArea(
installation.InstallationCode,
plant.PlantCode,
deck.Name
inspectionArea.Name
);

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

var testPose = new Pose
Expand All @@ -258,7 +258,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 @@ -296,7 +296,7 @@ public async Task ScheduleDuplicateCustomMissionDefinitions()
// Arrange
var installation = await _databaseUtilities.ReadOrNewInstallation();
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);
var deck = await _databaseUtilities.ReadOrNewDeck(
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(
installation.InstallationCode,
plant.PlantCode
);
Expand All @@ -312,7 +312,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 @@ -381,7 +381,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(
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(
installation.InstallationCode,
plant.PlantCode
);
Expand All @@ -396,7 +396,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 @@ -510,14 +510,14 @@ public async Task ScheduleDuplicatMissionDefinitions()
// Arrange - Initialise area
var installation = await _databaseUtilities.ReadOrNewInstallation();
var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode);
var deck = await _databaseUtilities.ReadOrNewDeck(
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(
installation.InstallationCode,
plant.PlantCode
);
var area = await _databaseUtilities.ReadOrNewArea(
installation.InstallationCode,
plant.PlantCode,
deck.Name
inspectionArea.Name
);

// Arrange - Robot
Expand Down Expand Up @@ -574,7 +574,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(
var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(
installation.InstallationCode,
plant.PlantCode
);
Expand All @@ -596,7 +596,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 @@ -637,33 +637,35 @@ 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(
string inspectionAreaName1 =
"inspectionAreaMissionFailsIfRobotIsNotInSameInspectionAreaAsMission1";
var inspectionArea1 = await _databaseUtilities.NewInspectionArea(
installation.InstallationCode,
plant.PlantCode,
deckName1
inspectionAreaName1
);

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

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

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

Expand All @@ -672,7 +674,7 @@ public async Task MissionFailsIfRobotIsNotInSameDeckAsMission()
{
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 @@ -106,7 +106,7 @@ public async Task RobotIsNotCreatedWithAreaNotInInstallation()
var wrongPlant = await _databaseUtilities.ReadOrNewPlant(
wrongInstallation.InstallationCode
);
var wrongDeck = await _databaseUtilities.ReadOrNewDeck(
var wrongInspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(
wrongInstallation.InstallationCode,
wrongPlant.PlantCode
);
Expand All @@ -122,7 +122,7 @@ public async Task RobotIsNotCreatedWithAreaNotInInstallation()
Host = "localhost",
Port = 3000,
CurrentInstallationCode = installation.InstallationCode,
CurrentInspectionAreaName = wrongDeck.Name,
CurrentInspectionAreaName = wrongInspectionArea.Name,
};

string robotUrl = "/robots";
Expand All @@ -140,7 +140,7 @@ public async Task RobotIsNotCreatedWithAreaNotInInstallation()
{
Assert.True(
ex.Message
== $"Could not create new robot in database as inspection area '{wrongDeck.Name}' does not exist in installation {installation.InstallationCode}"
== $"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 ac2b978

Please sign in to comment.