List<String> issuesNotChangedKeys();
- int totalIssuesChanged();
+ Integer totalIssuesChanged();
- int totalIssuesNotChanged();
+ Integer totalIssuesNotChanged();
}
import org.sonar.wsclient.issue.BulkChange;
+import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import java.util.ArrayList;
*/
public class DefaultBulkChange implements BulkChange {
- private int totalIssuesChanged;
- private int totalIssuesNotChanged;
+ private Integer totalIssuesChanged;
+ private Integer totalIssuesNotChanged;
private final List<String> issuesNotChangedKeys = new ArrayList<String>();
public List<String> issuesNotChangedKeys() {
return issuesNotChangedKeys;
}
- public int totalIssuesChanged() {
+ @CheckForNull
+ public Integer totalIssuesChanged() {
return totalIssuesChanged;
}
- public int totalIssuesNotChanged() {
+ @CheckForNull
+ public Integer totalIssuesNotChanged() {
return totalIssuesNotChanged;
}
- DefaultBulkChange setTotalIssuesChanged(@Nullable int totalIssuesChanged) {
+ DefaultBulkChange setTotalIssuesChanged(@Nullable Integer totalIssuesChanged) {
this.totalIssuesChanged = totalIssuesChanged;
return this;
}
- DefaultBulkChange setTotalIssuesNotChanged(@Nullable int totalIssuesNotChanged) {
+ DefaultBulkChange setTotalIssuesNotChanged(@Nullable Integer totalIssuesNotChanged) {
this.totalIssuesNotChanged = totalIssuesNotChanged;
return this;
}
*/
package org.sonar.wsclient.services;
-import javax.annotation.Nullable;
-
public class Authentication extends Model {
+
private boolean valid;
- public boolean isValid() {
+ public boolean isValid() {
return valid;
}
- public Authentication setValid(@Nullable boolean valid) {
+ public Authentication setValid(boolean valid) {
this.valid = valid;
return this;
}
return defaultProfile;
}
- public Profile setDefaultProfile(@Nullable boolean b) {
+ public Profile setDefaultProfile(boolean b) {
this.defaultProfile = b;
return this;
}
}
- private int page, pageSize, total;
+ private Integer page, pageSize, total;
private List<ResourceSearchResult.Resource> resources;
- public int getPage() {
+ @CheckForNull
+ public Integer getPage() {
return page;
}
- public int getTotal() {
+ @CheckForNull
+ public Integer getTotal() {
return total;
}
return resources;
}
- public void setPage(@Nullable int page) {
+ public void setPage(@Nullable Integer page) {
this.page = page;
}
- public void setTotal(@Nullable int total) {
+ public void setTotal(@Nullable Integer total) {
this.total = total;
}
- public int getPageSize() {
+ @CheckForNull
+ public Integer getPageSize() {
return pageSize;
}
- public void setPageSize(@Nullable int pageSize) {
+ public void setPageSize(@Nullable Integer pageSize) {
this.pageSize = pageSize;
}
import java.util.List;
public class AuthenticationUnmarshaller implements Unmarshaller<Authentication> {
+
public Authentication toModel(String json) {
WSUtils utils = WSUtils.getINSTANCE();
Object map = utils.parse(json);
- return new Authentication()
- .setValid(utils.getBoolean(map, "valid"));
+ Boolean validJson = utils.getBoolean(map, "valid");
+ return new Authentication().setValid(validJson != null ? validJson : false);
}
public List<Authentication> toModels(String json) {
protected Profile parse(Object json) {
WSUtils utils = WSUtils.getINSTANCE();
Profile profile = new Profile();
+ Boolean defaultProfile = utils.getBoolean(json, "default");
profile
.setLanguage(utils.getString(json, "language"))
.setName(utils.getString(json, "name"))
- .setDefaultProfile(utils.getBoolean(json, "default"))
+ .setDefaultProfile(defaultProfile != null ? defaultProfile : false)
.setParentName(utils.getString(json, "parent"));
parseRules(utils, profile, json);
*/
package org.sonar.wsclient.unmarshallers;
+import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.sonar.wsclient.services.ResourceSearchResult;
import org.sonar.wsclient.services.WSUtils;
result.setTotal(utils.getInteger(json, "total"));
List<ResourceSearchResult.Resource> resources = new ArrayList<ResourceSearchResult.Resource>();
- for (Object jsonResource : JsonUtils.getArray((JSONObject) json, "data")) {
- ResourceSearchResult.Resource resource = new ResourceSearchResult.Resource();
- resource.setKey(JsonUtils.getString((JSONObject) jsonResource, "key"));
- resource.setName(JsonUtils.getString((JSONObject) jsonResource, "nm"));
- resource.setQualifier(JsonUtils.getString((JSONObject) jsonResource, "q"));
- resources.add(resource);
+ JSONArray dataJson = JsonUtils.getArray((JSONObject) json, "data");
+ if (dataJson != null) {
+ for (Object jsonResource : dataJson) {
+ ResourceSearchResult.Resource resource = new ResourceSearchResult.Resource();
+ resource.setKey(JsonUtils.getString((JSONObject) jsonResource, "key"));
+ resource.setName(JsonUtils.getString((JSONObject) jsonResource, "nm"));
+ resource.setQualifier(JsonUtils.getString((JSONObject) jsonResource, "q"));
+ resources.add(resource);
+ }
}
result.setResources(resources);
return result;
import static org.fest.assertions.Assertions.assertThat;
public class AuthenticationTest {
+
@Test
public void should_set_valid_state() {
assertThat(new Authentication().isValid()).isFalse();