Skip to content

Commit

Permalink
Merge pull request eclipse-mylyn#498 from eclipse-mylyn/415-resolve-l…
Browse files Browse the repository at this point in the history
…ight-warnings-for-mylyn-bugzilla-rest-connector

resolve light warnings for mylyn bugzilla rest connector eclipse-mylyn#415
  • Loading branch information
gnl42 authored Apr 27, 2024
2 parents 0aae059 + 5b66c40 commit 37c8916
Show file tree
Hide file tree
Showing 45 changed files with 659 additions and 282 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Manifest-Version: 1.0
Automatic-Module-Name: org.eclipse.mylyn.bugzilla.rest.core.tests
Bundle-ManifestVersion: 2
Bundle-Name: Mylyn Bugzilla Rest Connector Tests
Bundle-SymbolicName: org.eclipse.mylyn.bugzilla.rest.core.tests;singleton:=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* Frank Becker - initial API and implementation
* See git history
*******************************************************************************/

package org.eclipse.mylyn.bugzilla.rest.core.tests;
Expand All @@ -25,8 +26,9 @@

@RunWith(ManagedSuite.class)
@Suite.SuiteClasses({ RepositoryKeyTest.class, BugzillaRestFlagMapperTest.class,
BugzillaRestConnectorNoFixtureTest.class })
BugzillaRestConnectorNoFixtureTest.class })
@TestConfigurationProperty()
@SuppressWarnings("restriction")
public class AllBugzillaRestCoreTests {
static {
if (CommonTestUtil.fixProxyConfiguration()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* Frank Becker - initial API and implementation
* See git history
*******************************************************************************/

package org.eclipse.mylyn.bugzilla.rest.core.tests;
Expand All @@ -27,6 +28,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -88,7 +90,7 @@

import com.google.gson.Gson;

@SuppressWarnings("restriction")
@SuppressWarnings({ "nls", "restriction" })
@RunWith(Junit4TestFixtureRunner.class)
@FixtureDefinition(fixtureClass = BugzillaRestTestFixture.class, fixtureType = "bugzillaREST")
// use this if you only want to run the test class if the property exists with
Expand Down Expand Up @@ -232,28 +234,32 @@ public void testGetConfiguration() throws Exception {
Collection<Field> fieldCollection = fields.values();
assertConfigurationFieldNames(fieldCollection);
assertEquals(
IOUtils.toString(CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/fields.json")),
IOUtils.toString(CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/fields.json"),
Charset.defaultCharset()),
new Gson().toJson(fields));
Map<String, Product> products = configuration.getProducts();
assertEquals(
IOUtils.toString(
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/products.json")),
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/products.json"),
Charset.defaultCharset()),
new Gson().toJson(products));
Parameters parameter = configuration.getParameters();
assertEquals(
IOUtils.toString(
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/parameters.json")),
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/parameters.json"),
Charset.defaultCharset()),
new Gson().toJson(parameter)
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url")
.replaceAll(repository.getRepositoryUrl().replaceFirst("https://", "http://"),
"http://dummy.url"));
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url")
.replaceAll(repository.getRepositoryUrl().replaceFirst("https://", "http://"),
"http://dummy.url"));
assertEquals(
IOUtils.toString(
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/configuration.json")),
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/configuration.json"),
Charset.defaultCharset()),
new Gson().toJson(configuration)
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url")
.replaceAll(repository.getRepositoryUrl().replaceFirst("https://", "http://"),
"http://dummy.url"));
.replaceAll(repository.getRepositoryUrl(), "http://dummy.url")
.replaceAll(repository.getRepositoryUrl().replaceFirst("https://", "http://"),
"http://dummy.url"));
}

private void assertConfigurationFieldNames(Collection<Field> fields) throws IOException {
Expand All @@ -264,7 +270,8 @@ private void assertConfigurationFieldNames(Collection<Field> fields) throws IOEx
Collections.sort(fieldNameList);
assertEquals(
IOUtils.toString(
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/fieldName.json")),
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/fieldName.json"),
Charset.defaultCharset()),
new Gson().toJson(fieldNameList));
}

Expand Down Expand Up @@ -294,19 +301,22 @@ public String getProduct() {
TaskData taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
assertTrue(taskDataHandler.initializeTaskData(repository, taskData, null, null));
assertEquals(
IOUtils.toString(CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/taskData.txt")),
IOUtils.toString(CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/taskData.txt"),
Charset.defaultCharset()),
taskData.getRoot().toString());
taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
assertTrue(taskDataHandler.initializeTaskData(repository, taskData, taskMappingInit, null));
assertEquals(
IOUtils.toString(
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/taskData1.txt")),
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/taskData1.txt"),
Charset.defaultCharset()),
taskData.getRoot().toString());
taskData = new TaskData(mapper, repository.getConnectorKind(), repository.getRepositoryUrl(), "");
assertTrue(taskDataHandler.initializeTaskData(repository, taskData, taskMappingSelect, null));
assertEquals(
IOUtils.toString(
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/taskData2.txt")),
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/taskData2.txt"),
Charset.defaultCharset()),
taskData.getRoot().toString());
}

Expand Down Expand Up @@ -419,8 +429,8 @@ public String getVersion() {
taskDataHandler.initializeTaskData(actualFixture.repository(), taskData, taskMappingInit, null);
taskData.getRoot().getAttribute("cf_dropdown").setValue("one");
taskData.getRoot()
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
.postTaskData(taskData, null, null);
assertEquals(ResponseKind.TASK_CREATED, reposonse.getReposonseKind());
Expand Down Expand Up @@ -461,8 +471,8 @@ public String getVersion() {
taskDataHandler.initializeTaskData(actualFixture.repository(), taskData, taskMappingInit, null);
taskData.getRoot().getAttribute("cf_dropdown").setValue("one");
taskData.getRoot()
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");

TaskData taskDataSubmit = new TaskData(mapper, actualFixture.repository().getConnectorKind(),
actualFixture.repository().getRepositoryUrl(), "");
Expand Down Expand Up @@ -507,8 +517,8 @@ public String getVersion() {

taskData.getRoot().getAttribute("cf_dropdown").setValue("one");
taskData.getRoot()
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
String taskId = harness.submitNewTask(taskData);
TaskData taskDataGet = harness.getTaskFromServer(taskId);

Expand All @@ -522,9 +532,9 @@ public String getVersion() {

// resolution is only for new tasks readonly
taskData.getRoot()
.getAttribute(BugzillaRestTaskSchema.getDefault().RESOLUTION.getKey())
.getMetaData()
.setReadOnly(false);
.getAttribute(BugzillaRestTaskSchema.getDefault().RESOLUTION.getKey())
.getMetaData()
.setReadOnly(false);

// attributes we know that they can not be equal
taskData.getRoot().removeAttribute(BugzillaRestTaskSchema.getDefault().STATUS.getKey());
Expand Down Expand Up @@ -571,7 +581,8 @@ public String getVersion() {
assertEquals(taskData.getRoot().toString(), taskDataGet.getRoot().toString());
assertEquals(
IOUtils.toString(
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/taskDataFlags.txt")),
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/taskDataFlags.txt"),
Charset.defaultCharset()),
flags.toString());
}

Expand Down Expand Up @@ -859,11 +870,11 @@ public String getVersion() {
taskDataHandler.initializeTaskData(actualFixture.repository(), taskData, taskMappingInit, null);
taskData.getRoot().getAttribute("cf_dropdown").setValue("one");
taskData.getRoot()
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
taskData.getRoot()
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().CC.getKey())
.setValue("[email protected], [email protected]");
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().CC.getKey())
.setValue("[email protected], [email protected]");
RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
.postTaskData(taskData, null, null);
assertNotNull(reposonse);
Expand Down Expand Up @@ -913,11 +924,11 @@ public String getVersion() {
taskDataHandler.initializeTaskData(actualFixture.repository(), taskData, taskMappingInit, null);
taskData.getRoot().getAttribute("cf_dropdown").setValue("one");
taskData.getRoot()
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
taskData.getRoot()
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().BLOCKS.getKey())
.setValue(taskIdRel[0] + ", " + taskIdRel[1]);
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().BLOCKS.getKey())
.setValue(taskIdRel[0] + ", " + taskIdRel[1]);
RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
.postTaskData(taskData, null, null);
assertNotNull(reposonse);
Expand Down Expand Up @@ -967,11 +978,11 @@ public String getVersion() {
taskDataHandler.initializeTaskData(actualFixture.repository(), taskData, taskMappingInit, null);
taskData.getRoot().getAttribute("cf_dropdown").setValue("one");
taskData.getRoot()
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().TARGET_MILESTONE.getKey())
.setValue("M2");
taskData.getRoot()
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().DEPENDS_ON.getKey())
.setValue(taskIdRel[0] + ", " + taskIdRel[1]);
.getAttribute(BugzillaRestCreateTaskSchema.getDefault().DEPENDS_ON.getKey())
.setValue(taskIdRel[0] + ", " + taskIdRel[1]);
RepositoryResponse reposonse = connector.getClient(actualFixture.repository())
.postTaskData(taskData, null, null);
assertNotNull(reposonse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* Contributors:
* Frank Becker - initial API and implementation
* See git history
*******************************************************************************/

package org.eclipse.mylyn.bugzilla.rest.core.tests;
Expand All @@ -17,6 +18,7 @@
import static org.junit.Assert.assertNotNull;

import java.io.IOException;
import java.nio.charset.Charset;

import org.apache.commons.io.IOUtils;
import org.eclipse.core.runtime.CoreException;
Expand All @@ -35,7 +37,7 @@

import com.google.gson.Gson;

@SuppressWarnings("restriction")
@SuppressWarnings({ "nls", "restriction" })
@RunWith(Junit4TestFixtureRunner.class)
@FixtureDefinition(fixtureClass = BugzillaRestTestFixture.class, fixtureType = "bugzillaREST")
//@RunOnlyWhenProperty(property = "default", value = "1")
Expand Down Expand Up @@ -72,11 +74,12 @@ public void testConfigurationFromConnector() throws CoreException, IOException {
assertNotNull(configuration);
assertEquals(
IOUtils.toString(
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/configuration.json")),
CommonTestUtil.getResource(this, actualFixture.getTestDataFolder() + "/configuration.json"),
Charset.defaultCharset()),
new Gson().toJson(configuration)
.replaceAll(actualFixture.getRepositoryUrl(), "http://dummy.url")
.replaceAll(actualFixture.getRepositoryUrl().replaceFirst("https://", "http://"),
"http://dummy.url"));
.replaceAll(actualFixture.getRepositoryUrl(), "http://dummy.url")
.replaceAll(actualFixture.getRepositoryUrl().replaceFirst("https://", "http://"),
"http://dummy.url"));

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*******************************************************************************
* Copyright (c) 2013 Frank Becker and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Frank Becker - initial API and implementation
* See git history
*******************************************************************************/

package org.eclipse.mylyn.bugzilla.rest.core.tests;

import static org.hamcrest.MatcherAssert.assertThat;
Expand All @@ -16,6 +30,7 @@
import org.junit.Before;
import org.junit.Test;

@SuppressWarnings({ "nls", "restriction" })
public class BugzillaRestConnectorNoFixtureTest {

private BugzillaRestConnector connector;
Expand Down Expand Up @@ -51,8 +66,8 @@ public void testHasTaskChanged() {
Date now = new Date();
task.setAttribute(BugzillaRestTaskSchema.getDefault().DATE_MODIFICATION.getKey(), "" + now.getTime());
taskData.getRoot()
.createAttribute(BugzillaRestTaskSchema.getDefault().DATE_MODIFICATION.getKey())
.setValue("" + (now.getTime() + 1));
.createAttribute(BugzillaRestTaskSchema.getDefault().DATE_MODIFICATION.getKey())
.setValue("" + (now.getTime() + 1));
assertTrue(connector.hasTaskChanged(repository, task, taskData));
}

Expand All @@ -63,8 +78,8 @@ public void testHasTaskChangedEmptyModificationDate() {
TaskTask task = new TaskTask(repository.getConnectorKind(), repository.getRepositoryUrl(), "123");
Date now = new Date();
taskData.getRoot()
.createAttribute(BugzillaRestTaskSchema.getDefault().DATE_MODIFICATION.getKey())
.setValue("" + now.getTime());
.createAttribute(BugzillaRestTaskSchema.getDefault().DATE_MODIFICATION.getKey())
.setValue("" + now.getTime());
assertTrue(connector.hasTaskChanged(repository, task, taskData));
}

Expand All @@ -76,8 +91,8 @@ public void testHasNotTaskChanged() {
Date now = new Date();
task.setAttribute(BugzillaRestTaskSchema.getDefault().DATE_MODIFICATION.getKey(), "" + now.getTime());
taskData.getRoot()
.createAttribute(BugzillaRestTaskSchema.getDefault().DATE_MODIFICATION.getKey())
.setValue("" + now.getTime());
.createAttribute(BugzillaRestTaskSchema.getDefault().DATE_MODIFICATION.getKey())
.setValue("" + now.getTime());
assertTrue(!connector.hasTaskChanged(repository, task, taskData));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*******************************************************************************
* Copyright (c) 2013 Frank Becker and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Frank Becker - initial API and implementation
* See git history
*******************************************************************************/

package org.eclipse.mylyn.bugzilla.rest.core.tests;

import static org.hamcrest.CoreMatchers.not;
Expand Down Expand Up @@ -36,6 +50,7 @@

@RunWith(Junit4TestFixtureRunner.class)
@FixtureDefinition(fixtureClass = BugzillaRestTestFixture.class, fixtureType = "bugzillaREST")
@SuppressWarnings({ "nls", "restriction" })
public class BugzillaRestConnectorTest {
private final BugzillaRestTestFixture actualFixture;

Expand Down
Loading

0 comments on commit 37c8916

Please sign in to comment.