开发者

Handling multiple string using REGEX in java [closed]

开发者 https://www.devze.com 2023-03-31 07:32 出处:网络
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post.
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

开发者_开发技巧

Closed 9 years ago.

Improve this question

I have 5 strings "a,b,c,d,e" in a drop down,i am writing a testcase where i am checking if the user has selected any of the five then insert into DB,currently i am not getting any of the values from client side,so it has to be written in a junit if the user has selected any of these values then return true .

current approach: 1st method having 'a' data JSONObject obj=new JSONObject(); obj.put("DT",a);

2nd method having 'b' data JSONObject obj=new JSONObject(); obj.put("DT",b);

and so on for furthur values.which is creating more number of methods.I need to insert all the values in a single method.

Thanks


I'm a bit confused as to what you're actually struggling with. Are you just looking for a helper method to do this?

public static JSONObject createAndPopulateObject(String data) {
  JSONObject obj = new JSONObject();
  obj.put("DT", data);
  return obj;
}

//...
aObj = createAndPopulateObject("a");
bObj = createAndPopulateObject("b");
0

精彩评论

暂无评论...
验证码 换一张
取 消