当前位置: 首页>>代码示例>>Java>>正文


Java JsonWriter.close方法代码示例

本文整理汇总了Java中org.sonar.api.utils.text.JsonWriter.close方法的典型用法代码示例。如果您正苦于以下问题:Java JsonWriter.close方法的具体用法?Java JsonWriter.close怎么用?Java JsonWriter.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sonar.api.utils.text.JsonWriter的用法示例。


在下文中一共展示了JsonWriter.close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import org.sonar.api.utils.text.JsonWriter; //导入方法依赖的package包/类
@Override
public void handle(final Request request, final Response response) {
	LOGGER.info("Handle issueresolver import request ...");
	final ImportResult importResult = new ImportResult();

	// Read issue data from request
	final Map<IssueKey, IssueData> issues = readIssues(request, importResult);
	LOGGER.info("Read " + importResult.getIssues() + " issues (having " + importResult.getDuplicateKeys()
			+ " duplicate keys)");

	IssueHelper.resolveIssues(request.localConnector(), importResult,
			request.mandatoryParamAsBoolean(PARAM_PREVIEW), request.mandatoryParamAsBoolean(PARAM_SKIP_ASSIGN),
			request.mandatoryParamAsBoolean(PARAM_SKIP_COMMENTS), request.mandatoryParam(PARAM_PROJECT_KEY),
			issues);

	// Sent result
	final JsonWriter responseWriter = response.newJsonWriter();
	importResult.write(responseWriter);
	responseWriter.close();
	LOGGER.debug("Issueresolver import request done");
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:22,代码来源:ImportAction.java

示例2: handle

import org.sonar.api.utils.text.JsonWriter; //导入方法依赖的package包/类
@Override
public void handle(final Request request, final Response response) {
	LOGGER.debug("Handle issueresolver export request");
	response.setHeader("Content-Disposition", "attachment; filename=\"resolved-issues.json\"");

	final JsonWriter responseWriter = response.newJsonWriter();
	writeStart(responseWriter);

	IssueHelper.forEachIssue(request.localConnector(),
			SearchHelper.findIssuesForExport(request.mandatoryParam(PARAM_PROJECT_KEY)), (searchIssuesResponse,
					issue) -> writeIssue(responseWriter, issue, searchIssuesResponse.getComponentsList()));

	writeEnd(responseWriter);
	responseWriter.close();
	LOGGER.debug("Issueresolver export request done");
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:17,代码来源:ExportAction.java

示例3: handle

import org.sonar.api.utils.text.JsonWriter; //导入方法依赖的package包/类
@Override
public void handle(final Request request, final Response response) {
	LOGGER.info("Handle issueresolver update request ...");
	final ImportResult importResult = new ImportResult();

	// Read issues from project
	final Map<IssueKey, IssueData> issues = new HashMap<>();
	IssueHelper.forEachIssue(request.localConnector(),
			SearchHelper.findIssuesForExport(request.mandatoryParam(PARAM_FROM_PROJECT_KEY)),
			(searchIssuesResponse, issue) -> {
				issues.put(IssueKey.fromIssue(issue, searchIssuesResponse.getComponentsList()),
						IssueData.fromIssue(issue));
				importResult.registerIssue();
			});
	LOGGER.info("Read " + importResult.getIssues() + " issues");

	IssueHelper.resolveIssues(request.localConnector(), importResult,
			request.mandatoryParamAsBoolean(PARAM_PREVIEW), request.mandatoryParamAsBoolean(PARAM_SKIP_ASSIGN),
			request.mandatoryParamAsBoolean(PARAM_SKIP_COMMENTS), request.mandatoryParam(PARAM_PROJECT_KEY),
			issues);

	// Sent result
	final JsonWriter responseWriter = response.newJsonWriter();
	importResult.write(responseWriter);
	responseWriter.close();
	LOGGER.debug("Issueresolver update request done");
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:28,代码来源:UpdateAction.java

示例4: test

import org.sonar.api.utils.text.JsonWriter; //导入方法依赖的package包/类
@Test
public void test() throws IOException {
	final Issue issue = ReflectionTestUtils.build(Issue.class, "status_", "RESOLVED", "resolution_", "FALSE-POSITIVE",
			"assignee_", "admin", "comments_",
			ReflectionTestUtils.build(Comments.class, "comments_",
					Arrays.asList(ReflectionTestUtils.build(Comment.class, "markdown_", "Comment one"),
							ReflectionTestUtils.build(Comment.class, "markdown_", "Comment two"))));

	final IssueData data = IssueData.fromIssue(issue);
	Assert.assertEquals("RESOLVED", data.getStatus());
	Assert.assertEquals("FALSE-POSITIVE", data.getResolution());
	Assert.assertEquals("admin", data.getAssignee());
	Assert.assertEquals(Arrays.asList("Comment one", "Comment two"), data.getComments());

	final String json;
	try (final StringWriter writer = new StringWriter()) {
		final JsonWriter jsonWriter = JsonWriter.of(writer);
		jsonWriter.beginObject();
		data.write(jsonWriter);
		jsonWriter.endObject();
		jsonWriter.close();

		json = writer.toString();
	}
	Assert.assertEquals("{\"status\":\"RESOLVED\",\"resolution\":\"FALSE-POSITIVE\",\"assignee\":\"admin\",\"comments\":[\"Comment one\",\"Comment two\"]}", json);

	final IssueData readData;
	try (final ByteArrayInputStream bais = new ByteArrayInputStream(json.getBytes("UTF-8"));
			final JsonReader reader = new JsonReader(bais)) {
		reader.beginObject();
		readData = IssueData.read(reader);
		reader.endObject();
	}
	
	Assert.assertEquals("RESOLVED", readData.getStatus());
	Assert.assertEquals("FALSE-POSITIVE", readData.getResolution());
	Assert.assertEquals("admin", readData.getAssignee());
	Assert.assertEquals(Arrays.asList("Comment one", "Comment two"), readData.getComments());
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:40,代码来源:IssueDataTest.java

示例5: test

import org.sonar.api.utils.text.JsonWriter; //导入方法依赖的package包/类
@Test
public void test() throws IOException {
	final Issue issue = ReflectionTestUtils.build(Issue.class, "rule_", "test:rule001", "component_",
			"nl.future-edge.sonarqube.plugins:sonar-issueresolver-plugin:src/main/java/nl/futureedge/sonar/plugin/issueresolver/issues/IssueKey.java",
			"textRange_", ReflectionTestUtils.build(TextRange.class, "startLine_", 13, "startOffset_", 65));
	final Component component = ReflectionTestUtils.build(Component.class, "key_", "nl.future-edge.sonarqube.plugins:sonar-issueresolver-plugin:src/main/java/nl/futureedge/sonar/plugin/issueresolver/issues/IssueKey.java",
		"longName_", "src/main/java/nl/futureedge/sonar/plugin/issueresolver/issues/IssueKey.java");
	final List<Component> components = Arrays.asList(component);

	final IssueKey key = IssueKey.fromIssue(issue, components);

	final String json;
	try (final StringWriter writer = new StringWriter()) {
		final JsonWriter jsonWriter = JsonWriter.of(writer);
		jsonWriter.beginObject();
		key.write(jsonWriter);
		jsonWriter.endObject();
		jsonWriter.close();

		json = writer.toString();
	}
	Assert.assertEquals(
			"{\"longName\":\"src/main/java/nl/futureedge/sonar/plugin/issueresolver/issues/IssueKey.java\",\"rule\":\"test:rule001\",\"line\":13}",
			json);

	final IssueKey readKey;
	try (final ByteArrayInputStream bais = new ByteArrayInputStream(json.getBytes("UTF-8"));
			final JsonReader reader = new JsonReader(bais)) {
		reader.beginObject();
		readKey = IssueKey.read(reader);
		reader.endObject();
	}

	Assert.assertEquals(key.hashCode(), readKey.hashCode());
	Assert.assertEquals(key, readKey);
	Assert.assertFalse(key.equals(null));
	Assert.assertTrue(key.equals(key));
	Assert.assertFalse(key.equals(new Object()));
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:40,代码来源:IssueKeyTest.java

示例6: writeEnd

import org.sonar.api.utils.text.JsonWriter; //导入方法依赖的package包/类
private void writeEnd(final JsonWriter writer) {
	writer.endArray();
	writer.endObject();
	writer.close();
}
 
开发者ID:willemsrb,项目名称:sonar-issueresolver-plugin,代码行数:6,代码来源:ExportAction.java


注:本文中的org.sonar.api.utils.text.JsonWriter.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。