@@ -576,6 +576,7 @@ pub struct Review {
576
576
/// The result of a style check.
577
577
#[ derive( Debug , Deserialize , Serialize , PartialEq , Eq , JsonSchema ) ]
578
578
#[ cfg_attr( feature = "ts-rs" , derive( ts_rs:: TS ) ) ]
579
+ #[ serde( rename_all = "camelCase" ) ]
579
580
pub struct TmcStyleValidationResult {
580
581
pub strategy : TmcStyleValidationStrategy ,
581
582
pub validation_errors : Option < HashMap < PathBuf , Vec < TmcStyleValidationError > > > ,
@@ -594,6 +595,7 @@ pub enum TmcStyleValidationStrategy {
594
595
/// A style validation error.
595
596
#[ derive( Debug , Deserialize , Serialize , PartialEq , Eq , JsonSchema ) ]
596
597
#[ cfg_attr( feature = "ts-rs" , derive( ts_rs:: TS ) ) ]
598
+ #[ serde( rename_all = "camelCase" ) ]
597
599
pub struct TmcStyleValidationError {
598
600
pub column : u32 ,
599
601
pub line : u32 ,
@@ -695,4 +697,81 @@ mod test {
695
697
let json = serde_json:: to_string ( & original) . unwrap ( ) ;
696
698
assert_eq ! ( json, r#"{"IntRange":{"lower":1,"upper":5}}"# ) ;
697
699
}
700
+
701
+ #[ test]
702
+ fn submission_response_with_validation_errors ( ) {
703
+ init ( ) ;
704
+
705
+ let submission = serde_json:: json!(
706
+ {
707
+ "api_version" : 7 ,
708
+ "all_tests_passed" : false ,
709
+ "user_id" : 12345 ,
710
+ "login" : "12345" ,
711
+ "course" : "course" ,
712
+ "exercise_name" : "exercise" ,
713
+ "status" : "fail" ,
714
+ "points" : [ ] ,
715
+ "validations" : {
716
+ "strategy" : "FAIL" ,
717
+ "validationErrors" : {
718
+ "Main.java" : [
719
+ {
720
+ "column" : 1 ,
721
+ "line" : 1 ,
722
+ "message" : "Indentation incorrect. Expected 8, but was 12." ,
723
+ "sourceName" : "com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck"
724
+ } ,
725
+ {
726
+ "column" : 2 ,
727
+ "line" : 2 ,
728
+ "message" : "Indentation incorrect. Expected 8, but was 12." ,
729
+ "sourceName" : "com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck"
730
+ }
731
+ ]
732
+ }
733
+ } ,
734
+ "valgrind" : "" ,
735
+ "submission_url" : "https://tmc.mooc.fi/submissions/12345" ,
736
+ "solution_url" : "https://tmc.mooc.fi/exercises/12345/solution" ,
737
+ "submitted_at" : "2025-01-01T01:01:01.001+01:01" ,
738
+ "processing_time" : 12345 ,
739
+ "reviewed" : false ,
740
+ "requests_review" : false ,
741
+ "paste_url" : null,
742
+ "message_for_paste" : null,
743
+ "missing_review_points" : [ ] ,
744
+ "test_cases" : [
745
+ {
746
+ "name" : "FakeTest test" ,
747
+ "successful" : true ,
748
+ "message" : "" ,
749
+ "exception" : [ ] ,
750
+ "detailed_message" : null
751
+ } ,
752
+ {
753
+ "name" : "FakeTest testTwo" ,
754
+ "successful" : true ,
755
+ "message" : "" ,
756
+ "exception" : [ ] ,
757
+ "detailed_message" : null
758
+ } ,
759
+ {
760
+ "name" : "FakeTest testThree" ,
761
+ "successful" : true ,
762
+ "message" : "" ,
763
+ "exception" : [ ] ,
764
+ "detailed_message" : null
765
+ }
766
+ ]
767
+ }
768
+ ) ;
769
+ let submission = deserialize:: json_from_value :: < SubmissionFinished > ( submission) . unwrap ( ) ;
770
+ assert ! ( !submission
771
+ . validations
772
+ . unwrap( )
773
+ . validation_errors
774
+ . unwrap( )
775
+ . is_empty( ) ) ;
776
+ }
698
777
}
0 commit comments