为什么运行testcases时出错

时间:2017-10-28 10:44:41

标签: python

 package com.aryvart.myaromasupply.Adapter;

import android.content.Context;
import android.support.v7.widget.CardView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.Toast;
import com.aryvart.myaromasupply.Bean.CommonBean;
import com.aryvart.myaromasupply.MyInterface;
import com.aryvart.myaromasupply.R;
import com.like.LikeButton;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.List;

/**
 * Created by android01 on 28/8/17.
 */

public class CartListAdapterKV extends BaseAdapter {
    private List<CommonBean> commonBeanList;
    Context c;
    MyInterface my_interface;
    private static LayoutInflater inflater = null;
    HashMap<String, JSONObject> hsMap = new HashMap<String, JSONObject>();

    // constructor
    public CartListAdapterKV(List<CommonBean> movieList, Context context, MyInterface inter) {
        this.commonBeanList = movieList;
        Log.e("NN", "size-->" + this.commonBeanList);
        this.c = context;
        this.my_interface = inter;
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public int getCount() {
        return commonBeanList.size();
    }

    public Object getItem(int position) {
        return commonBeanList.get(position);
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(final int position, View convertView, ViewGroup parent) {
        View view = convertView;
        if (convertView == null)
            view = inflater.inflate(R.layout.cart_items_kv, parent, false);
        TextView txt_cartTitle;
        final CheckBox cb_box;
        txt_cartTitle = (TextView) view.findViewById(R.id.textView2);
        cb_box = (CheckBox) view.findViewById(R.id.checkBoxKV);
        final CommonBean recyclerBean = commonBeanList.get(position);
        cb_box.setChecked(true);
        txt_cartTitle.setText(recyclerBean.getStr_cart_title());

        //check if checkbox is checked. if yes the add value to hashmap(by default all checkboxes will be checked in listview

        if (cb_box.isChecked()) {
            Toast.makeText(c, "--" + recyclerBean.getStr_cart_title(), Toast.LENGTH_SHORT).show();
            //JSONArray req = new JSONArray();
            JSONObject jsoBj = new JSONObject();
            try {

                jsoBj.put("id", recyclerBean.getStr_cart_id());
                jsoBj.put("value", recyclerBean.getStr_cart_title());
                jsoBj.put("checked", "true");

            } catch (JSONException e) {
                e.printStackTrace();
            }
            hsMap.put(recyclerBean.getStr_cart_id(), jsoBj);
            my_interface.getUnCheckedVal(hsMap, recyclerBean.getStr_cart_id());
            Log.e("NN", "AdpaMap--" + hsMap.toString());

        } else {

            JSONObject jsoBj = new JSONObject();
            try {
                jsoBj.put("id", recyclerBean.getStr_cart_id());
                jsoBj.put("value", recyclerBean.getStr_cart_title());
                jsoBj.put("checked", "false");

            } catch (JSONException e) {
                e.printStackTrace();
            }

            //adding the json object in hashmap to remove duplicates
            hsMap.put(recyclerBean.getStr_cart_id(), jsoBj);
            my_interface.getUnCheckedVal(hsMap, recyclerBean.getStr_cart_id());
            Toast.makeText(c, "-*-" + recyclerBean.getStr_cart_title(), Toast.LENGTH_SHORT).show();
        }
        cb_box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                final CommonBean recyclerBean = commonBeanList.get(position);
                if (cb_box.isChecked()) {
                    Toast.makeText(c, "--" + recyclerBean.getStr_cart_title(), Toast.LENGTH_SHORT).show();
                    JSONObject jsoBj = new JSONObject();
                    try {

                        jsoBj.put("id", recyclerBean.getStr_cart_id());
                        jsoBj.put("value", recyclerBean.getStr_cart_title());
                        jsoBj.put("checked", "true");

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    hsMap.put(recyclerBean.getStr_cart_id(), jsoBj);
                    my_interface.getUnCheckedVal(hsMap, recyclerBean.getStr_cart_id());
                    Log.e("NN", "AdpaMap--" + hsMap.toString());

                } else {

                    JSONObject jsoBj = new JSONObject();
                    try {
                        jsoBj.put("id", recyclerBean.getStr_cart_id());
                        jsoBj.put("value", recyclerBean.getStr_cart_title());
                        jsoBj.put("checked", "false");

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    hsMap.put(recyclerBean.getStr_cart_id(), jsoBj);
                    my_interface.getUnCheckedVal(hsMap, recyclerBean.getStr_cart_id());
                    Toast.makeText(c, "-*-" + recyclerBean.getStr_cart_title(), Toast.LENGTH_SHORT).show();
                }
            }
        });
        return view;
    }
}

如果此行CREATE TABLE promo_codes_definitions ( id serial PRIMARY KEY ,emission_id integer REFERENCES promo_codes_emissions(id) ,when_created timestamp NOT NULL DEFAULT TIMEZONE('UTC', NOW()) ); INSERT INTO promo_codes_definitions(emission_id, when_created) SELECT pce.id, pce.when_created FROM promo_codes_emissions pce; UPDATE promo_codes_emissions pce SET promo_codes_definition_id = pcd.id FROM promo_codes_definitions pcd WHERE pce.id = pcd.emission_id; ALTER TABLE promo_codes_definitions DROP COLUMN emission_id; 将是This method extract images from article ,but i have an issue when run test cases 第一个测试用例运行,但第二个没有。

matching_image = image.re(regex)

测试用例

matching_image = image.re(regex[0])

0 个答案:

没有答案