@@ -527,5 +527,56 @@ await TestSetupHelpers.WaitFor(async () =>
527527 return result . InspectionId == message . InspectionId ;
528528 } ) ;
529529 }
530+
531+ [ Fact ]
532+ public async Task TestMQTTSaraAnalysisResult ( )
533+ {
534+ var installation = await DatabaseUtilities . NewInstallation ( ) ;
535+ var plant = await DatabaseUtilities . NewPlant ( installation . InstallationCode ) ;
536+ var inspectionArea = await DatabaseUtilities . NewInspectionArea (
537+ installation . InstallationCode ,
538+ plant . PlantCode
539+ ) ;
540+ var robot = await DatabaseUtilities . NewRobot (
541+ RobotStatus . Busy ,
542+ installation ,
543+ inspectionArea . Id
544+ ) ;
545+ MissionTask task = new MissionTask { RobotPose = new Pose { } } ;
546+ var missionRun = await DatabaseUtilities . NewMissionRun (
547+ installation . InstallationCode ,
548+ robot ,
549+ inspectionArea ,
550+ writeToDatabase : true ,
551+ missionStatus : MissionStatus . Ongoing ,
552+ tasks : new MissionTask [ ] { task }
553+ ) ;
554+ var isarInspectionId = missionRun . Tasks [ 0 ] . Inspection ! . IsarInspectionId ;
555+
556+ const string VALUE = "testvalue" ;
557+ var message = new SaraAnalysisResultMessage
558+ {
559+ InspectionId = isarInspectionId ,
560+ AnalysisType = "test_analysis" ,
561+ StorageAccount = "testaccount" ,
562+ BlobContainer = installation . InstallationCode ,
563+ BlobName = "testblob" ,
564+ Value = VALUE ,
565+ } ;
566+ var messageString = JsonSerializer . Serialize ( message ) ;
567+ await MqttService . PublishMessageBasedOnTopic (
568+ $ "sara/analysis_result_available",
569+ messageString
570+ ) ;
571+
572+ await TestSetupHelpers . WaitFor ( async ( ) =>
573+ {
574+ var inspection = await InspectionService . ReadByIsarInspectionId (
575+ isarInspectionId ,
576+ readOnly : true
577+ ) ;
578+ return inspection ? . AnalysisResult ? . Value == VALUE ;
579+ } ) ;
580+ }
530581 }
531582}
0 commit comments