pub fn parse_response_body(
        &mut self,
        test_body: Map<String, Value>,
        res_body: Map<String, Value>,
    ) -> bool {
        fn parse_body(
            this: &mut Interpreter,
            test_body: Map<String, Value>,
            res_body: Map<String, Value>,
        ) -> bool {
            let mut passed = true;
            let mut test_body_iter = test_body.iter();

            while let Some((tk, tv)) = test_body_iter.next() {
                let checked = match res_body.get(tk) {
                    Some(val) => match val {
                        Value::Object(obj) => {
                            if let Value::Object(obj2) = tv {
                                parse_body(this, obj2.to_owned(), obj.to_owned())
                            } else {
                                this.response_value(tv.to_owned(), Value::Object(obj.to_owned()))
                            }
                        }
                        Value::Array(arr) => {
                            if let Value::Array(arr2) = tv {
                                let mut arr_iter = arr.iter();
                                let mut arr_passed = true;

                                while let Some(val) = arr_iter.next() {
                                    let mut arr2_iter = arr2.iter();

                                    while let Some(val2) = arr2_iter.next() {
                                        match val2 {
                                            Value::Object(val2_obj) => {
                                                if let Value::Object(val_obj) = val {
                                                    if !parse_body(
                                                        this,
                                                        val2_obj.to_owned(),
                                                        val_obj.to_owned(),
                                                    ) {
                                                        arr_passed = false;
                                                    }
                                                } else {
                                                    arr_passed = false;
                                                }
                                            }
                                            _ => {
                                                if !this
                                                    .response_value(val2.to_owned(), val.to_owned())
                                                {
                                                    arr_passed = false;
                                                }
                                            }
                                        }
                                    }
                                }

                                arr_passed
                            } else {
                                this.response_value(tv.to_owned(), Value::Array(arr.to_owned()))
                            }
                        }
                        _ => this.response_value(tv.to_owned(), val.to_owned()),
                    },
                    None => {
                        this.log_assertion(false, &format!("{}", tv), "Not Supplied");

                        false
                    }
                };

                if !checked {
                    passed = false;
                }
            }

            passed
        }

        parse_body(self, test_body, res_body)
    }
/// Checking the weather the test case response body
/// and the actual response body are matching
Checking the weather the test case response body
and the actual response body are matching
Checking the weather the test case response body and the actual response body are matching
pub fn parse_response_body(
        &mut self,
        test_body: Map<String, Value>,
        res_body: Map<String, Value>,
    ) -> bool {
        fn parse_body(
            this: &mut Interpreter,
            test_body: Map<String, Value>,
            res_body: Map<String, Value>,
        ) -> bool {
            let mut passed = true;
            let mut test_body_iter = test_body.iter();
            while let Some((tk, tv)) = test_body_iter.next() {
                let checked = match res_body.get(tk) {
                    Some(val) => match val {
                        Value::Object(obj) => {
                            if let Value::Object(obj2) = tv {
                                parse_body(this, obj2.to_owned(), obj.to_owned())
                            } else {
                                this.response_value(tv.to_owned(), Value::Object(obj.to_owned()))
                            }
                        }
                        Value::Array(arr) => {
                            if let Value::Array(arr2) = tv {
                                let mut arr_iter = arr.iter();
                                let mut arr_passed = true;
                                while let Some(val) = arr_iter.next() {
                                    let mut arr2_iter = arr2.iter();
                                    while let Some(val2) = arr2_iter.next() {
                                        match val2 {
                                            Value::Object(val2_obj) => {
                                                if let Value::Object(val_obj) = val {
                                                    if !parse_body(
                                                        this,
                                                        val2_obj.to_owned(),
                                                        val_obj.to_owned(),
                                                    ) {
                                                        arr_passed = false;
                                                    }
                                                } else {
                                                    arr_passed = false;
                                                }
                                            }
                                            _ => {
                                                if !this
                                                    .response_value(val2.to_owned(), val.to_owned())
                                                {
                                                    arr_passed = false;
                                                }
                                            }
                                        }
                                    }
                                }
                                arr_passed
                            } else {
                                this.response_value(tv.to_owned(), Value::Array(arr.to_owned()))
                            }
                        }
                        _ => this.response_value(tv.to_owned(), val.to_owned()),
                    },
                    None => {
                        this.log_assertion(false, &format!("{}", tv), "Not Supplied");
                        false
                    }
                };
                if !checked {
                    passed = false;
                }
            }
            passed
        }
        parse_body(self, test_body, res_body)
    }
pub fn parse_response_body ( & mut self , test_body : Map < String , Value > , res_body : Map < String , Value > , ) -> bool { fn parse_body ( this : & mut Interpreter , test_body : Map < String , Value > , res_body : Map < String , Value > , ) -> bool { let mut passed = true ; let mut test_body_iter = test_body . iter ( ) ; while let Some ( ( tk , tv ) ) = test_body_iter . next ( ) { let checked = match res_body . get ( tk ) { Some ( val ) => match val { Value :: Object ( obj ) => { if let Value :: Object ( obj2 ) = tv { parse_body ( this , obj2 . to_owned ( ) , obj . to_owned ( ) ) } else { this . response_value ( tv . to_owned ( ) , Value :: Object ( obj . to_owned ( ) ) ) } } Value :: Array ( arr ) => { if let Value :: Array ( arr2 ) = tv { let mut arr_iter = arr . iter ( ) ; let mut arr_passed = true ; while let Some ( val ) = arr_iter . next ( ) { let mut arr2_iter = arr2 . iter ( ) ; while let Some ( val2 ) = arr2_iter . next ( ) { match val2 { Value :: Object ( val2_obj ) => { if let Value :: Object ( val_obj ) = val { if ! parse_body ( this , val2_obj . to_owned ( ) , val_obj . to_owned ( ) , ) { arr_passed = false ; } } else { arr_passed = false ; } } _ => { if ! this . response_value ( val2 . to_owned ( ) , val . to_owned ( ) ) { arr_passed = false ; } } } } } arr_passed } else { this . response_value ( tv . to_owned ( ) , Value :: Array ( arr . to_owned ( ) ) ) } } _ => this . response_value ( tv . to_owned ( ) , val . to_owned ( ) ) , } , None => { this . log_assertion ( false , & format ! ( " " tv ) , " " ) ; false } } ; if ! checked { passed = false ; } } passed } parse_body ( self , test_body , res_body ) }
Checking the weather the test case response body
and the actual response body are matching
Checking the weather the test case response body and the actual response body are matching
&mut self
test_body
Map<String, Value>
res_body
Map<String, Value>