小编Sha*_*jan的帖子

在windows power shell中读取json响应

我使用的是power shell代码:

   $web_client = new-object system.net.webclient
    $build_info=web_client.DownloadString("http://<URL>")
    $suitevm_build_number=
    $suitevmCLN=
    $webapp_build=
    $stats_build=
Run Code Online (Sandbox Code Playgroud)

在点击http://时在浏览器中输出是:

{"message":null,"changeset":"340718","branch":"main","product":"productname","buildNumber":"1775951","todaysDate":"28-4-2014"}
Run Code Online (Sandbox Code Playgroud)

我该怎么写power shell代码才能获得:

  $suitevm_build_number=
    $suitevmCLN=
    $webapp_build=
    $stats_build=
Run Code Online (Sandbox Code Playgroud)

powershell json

10
推荐指数
1
解决办法
2万
查看次数

使用 Spring MongoOperations 根据查询获取所有文档

我的用户 POJO 如下所示:

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

@Document(collection = "User")
public class User {
    @Id
    private String id;
    private String username;
    private String password;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
}
Run Code Online (Sandbox Code Playgroud)

我能够根据此查询获取单个文档:

Query searchQuery = new Query(Criteria.where("name").is("shashi"));
mongoOperations.findOne(searchQuery, …
Run Code Online (Sandbox Code Playgroud)

java spring-data-mongodb

5
推荐指数
1
解决办法
1万
查看次数

当有多个 any 参数时定义 mockito

我正在尝试when使用多个any参数定义mockito 方法:

TestBedDaoClient testBedDaoClient = mock(TestBedDaoClient.class);
when(testBedDaoClient.addTestBed(anyString(), anyString(), any(VCloudConfiguration.class))).thenReturn(testBedPojoMockData);
Run Code Online (Sandbox Code Playgroud)

在目标测试类中:

TestBedPojo addedTestBedPojo = testBedDaoClient.addTestBed(testBedName, testBedDescription, vCloudConfiguration);
Run Code Online (Sandbox Code Playgroud)

在 DAO 客户端中:

public TestBedPojo addTestBed(String testBedName, String testBedDescription, VCloudConfiguration vCloudConfiguration){
     return testBedPojo;
}
Run Code Online (Sandbox Code Playgroud)

我想以when这样一种方式定义它返回testBedPojoMockData任何参数值。但我收到错误:Argument(s) are different!

我什至试过:

when(testBedDaoClient.addTestBed("test", "test", any(VCloudConfiguration.class))).thenReturn(testBedPojoMockData);
when(testBedDaoClient.addTestBed(any(), any(), any())).thenReturn(testBedPojoMockData);
Run Code Online (Sandbox Code Playgroud)

但没有运气。我如何定义它when以便它在任何调用中返回模拟数据?

java unit-testing mockito

5
推荐指数
1
解决办法
1万
查看次数

在一个testng xml中包含多个testng xmls

我有很多testng文件,每个文件都有十多个类调用测试.我想将所有testng文件包含在一个文件中.一种方法是复制所有内容并粘贴到一个testng xml中,但这里的问题是xml变得很长.testng/java有没有其他技术可以做到这一点?

java testng

1
推荐指数
1
解决办法
1946
查看次数

使用powershell获取json键值

我有以下json输出字符串:

{
    "meta": {
        "limit": 20,
        "next": null,
        "offset": 0,
        "previous": null,
        "total_count": 1
    },
    "objects": [{
        "bcontext": "/api/v2.0/buildercontext/2/",
        "bugs": [],
        "build": {
            "bldtype": "obj",
            "branch": "main",
            "buildstatus": [{
                "build": "/api/v2.0/build/2140634/",
                "failurereason": "_checkfailures (seen: FAIL - /testrun/18647678/ - area[4769] AIM-SANITY)",
                "id": "1294397",
                "lastupdate": "2015-03-31T14:30:18",
                "overridden": false,
                "overridedesc": "",
                "overrideuser": null,
                "recommended": false,
                "resource_uri": "/api/v2.0/buildstatus/1294397/",
                "slatype": {
                    "id": "26",
                    "name": "VA_Bats",
                    "resource_uri": "/api/v2.0/sla/26/"
                }
            }],
            "changeset": "494625",
            "coverage": false,
            "deliverables": ["/api/v2.0/deliverable/4296455/", "/api/v2.0/deliverable/4296956/", "/api/v2.0/deliverable/4296959/", "/api/v2.0/deliverable/4296986/", "/api/v2.0/deliverable/4296992/", "/api/v2.0/deliverable/4296995/", "/api/v2.0/deliverable/4297034/", "/api/v2.0/deliverable/4297058/"],
            "git_host": null,
            "git_repo": …
Run Code Online (Sandbox Code Playgroud)

powershell

0
推荐指数
1
解决办法
5634
查看次数