diff options
Diffstat (limited to 'connector-bugzilla-rest')
24 files changed, 502 insertions, 103 deletions
diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/META-INF/MANIFEST.MF b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/META-INF/MANIFEST.MF index 45032365d..425dc786e 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/META-INF/MANIFEST.MF +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/META-INF/MANIFEST.MF @@ -8,4 +8,8 @@ Fragment-Host: org.eclipse.mylyn.bugzilla.rest.core Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Require-Bundle: org.junit;bundle-version="4.8.2", org.eclipse.mylyn.commons.sdk.util +Require-Bundle: org.junit;bundle-version="4.8.2", + org.eclipse.mylyn.commons.sdk.util, + com.google.guava;bundle-version="10.0.1", + org.apache.commons.io Export-Package: org.eclipse.mylyn.internal.bugzilla.rest.core;x-internal:=true diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestClientTest.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestClientTest.java index 6432728e3..fc8d8d6e4 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestClientTest.java +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestClientTest.java @@ -16,19 +16,27 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import org.eclipse.mylyn.commons.net.AuthenticationCredentials; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.apache.commons.io.IOUtils; import org.eclipse.mylyn.commons.repositories.core.RepositoryLocation; import org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationType; import org.eclipse.mylyn.commons.repositories.core.auth.UserCredentials; import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil; -import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil.PrivilegeLevel; import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner; import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner.FixtureDefinition; import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestClient; +import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConfiguration; import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConnector; import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestException; import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestVersion; -import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.BugzillaRestLoginToken; +import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.Field; +import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.LoginToken; import org.eclipse.mylyn.internal.bugzilla.rest.test.support.BugzillaRestTestFixture; import org.eclipse.mylyn.internal.commons.core.operations.NullOperationMonitor; import org.eclipse.mylyn.internal.commons.repositories.core.InMemoryCredentialsStore; @@ -42,6 +50,8 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import com.google.gson.Gson; + @SuppressWarnings("restriction") @RunWith(Junit4TestFixtureRunner.class) @FixtureDefinition(fixtureClass = BugzillaRestTestFixture.class, fixtureType = "bugzillaREST") @@ -86,17 +96,6 @@ public class BugzillaRestClientTest { } @Test - public void testConnectorClientCacheRepositoryNotInManagerFailwithID() throws Exception { - TaskRepository repository = new TaskRepository(actualFixture.getConnectorKind(), - actualFixture.getRepositoryUrl()); - UserCredentials credentials = CommonTestUtil.getCredentials(PrivilegeLevel.USER); - repository.setCredentials(org.eclipse.mylyn.commons.net.AuthenticationType.REPOSITORY, - new AuthenticationCredentials(credentials.getUserName(), credentials.getPassword()), true); - BugzillaRestClient client1 = connector.getClient(repository); - assertNotNull(client1); - } - - @Test public void testGetVersion() throws Exception { BugzillaRestClient client = new BugzillaRestClient(actualFixture.location()); assertNotNull(client.getClient()); @@ -113,7 +112,7 @@ public class BugzillaRestClientTest { assertNull(client.getClient().getLoginToken()); assertTrue(client.validate(new NullOperationMonitor())); assertNotNull(client.getClient()); - BugzillaRestLoginToken token = client.getClient().getLoginToken(); + LoginToken token = client.getClient().getLoginToken(); assertNotNull(token); assertEquals("2", token.getId()); assertNotNull(token.getToken()); @@ -151,4 +150,43 @@ public class BugzillaRestClientTest { assertNull(client.getClient().getLoginToken()); client.validate(new NullOperationMonitor()); } -}
\ No newline at end of file + + @Test + public void testGetFields() throws Exception { + BugzillaRestClient client = connector.getClient(actualFixture.repository()); + Map<String, Field> fields = client.getFields(new NullOperationMonitor()); + Collection<Field> fieldCollection = fields.values(); + assertConfigurationFieldNames(fieldCollection); + assertEquals( + IOUtils.toString(CommonTestUtil.getResource(this, "testdata/" + actualFixture.getVersion() + + "/fields.json")), new Gson().toJson(fields)); + } + + @Test + public void testGetConfiguration() throws Exception { + TaskRepository repository = actualFixture.repository(); + BugzillaRestClient client = connector.getClient(repository); + BugzillaRestConfiguration configuration = client.getConfiguration(repository, new NullOperationMonitor()); + Map<String, Field> fields = client.getFields(new NullOperationMonitor()); + Collection<Field> fieldCollection = fields.values(); + assertConfigurationFieldNames(fieldCollection); + String ss = new Gson().toJson(configuration).replaceAll(repository.getRepositoryUrl(), "http://dummy.url"); + assertEquals( + IOUtils.toString(CommonTestUtil.getResource(this, "testdata/" + actualFixture.getVersion() + + "/configuration.json")), + new Gson().toJson(configuration).replaceAll(repository.getRepositoryUrl(), "http://dummy.url")); + + } + + private void assertConfigurationFieldNames(Collection<Field> fields) throws IOException { + List<String> fieldNameList = new ArrayList<String>(fields.size()); + for (Field field : fields) { + fieldNameList.add(field.getName()); + } + Collections.sort(fieldNameList); + assertEquals( + IOUtils.toString(CommonTestUtil.getResource(this, "testdata/" + actualFixture.getVersion() + + "/fieldName.json")), new Gson().toJson(fieldNameList)); + } + +} diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestConfigurationTest.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestConfigurationTest.java index 2ff339046..7b5cf074e 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestConfigurationTest.java +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestConfigurationTest.java @@ -11,23 +11,32 @@ package org.eclipse.mylyn.internal.bugzilla.rest.core.tests; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.io.IOException; + +import org.apache.commons.io.IOUtils; import org.eclipse.core.runtime.CoreException; +import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil; import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner; import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner.FixtureDefinition; +import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConfiguration; import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConnector; import org.eclipse.mylyn.internal.bugzilla.rest.core.RepositoryKey; import org.eclipse.mylyn.internal.bugzilla.rest.test.support.BugzillaRestTestFixture; import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager; import org.eclipse.mylyn.tasks.core.TaskRepository; +import org.junit.After; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; +import com.google.gson.Gson; + @SuppressWarnings("restriction") @RunWith(Junit4TestFixtureRunner.class) @FixtureDefinition(fixtureClass = BugzillaRestTestFixture.class, fixtureType = "bugzillaREST") @@ -37,6 +46,8 @@ public class BugzillaRestConfigurationTest { private static TaskRepositoryManager manager; + private BugzillaRestConnector connector; + public BugzillaRestConfigurationTest(BugzillaRestTestFixture fixture) { this.actualFixture = fixture; } @@ -46,6 +57,17 @@ public class BugzillaRestConfigurationTest { manager = new TaskRepositoryManager(); } + @Before + public void setUp() { + manager.addRepository(actualFixture.repository()); + connector = new BugzillaRestConnector(); + } + + @After + public void tearDown() throws Exception { + manager.clearRepositories(); + } + @Test public void testRepositoryKey() throws CoreException { RepositoryKey rep1 = new RepositoryKey(new TaskRepository("xx", "url")); @@ -57,10 +79,14 @@ public class BugzillaRestConfigurationTest { } @Test - public void testConfigurationFromConnector() throws CoreException { - BugzillaRestConnector connector = new BugzillaRestConnector(); - assertNotNull(connector); - assertNull(connector.getRepositoryConfiguration(actualFixture.repository())); + public void testConfigurationFromConnector() throws CoreException, IOException { + BugzillaRestConfiguration configuration = connector.getRepositoryConfiguration(actualFixture.repository()); + assertNotNull(configuration); + assertEquals( + IOUtils.toString(CommonTestUtil.getResource(this, "testdata/" + actualFixture.getVersion() + + "/configuration.json")), + new Gson().toJson(configuration).replaceAll(actualFixture.repository().getRepositoryUrl(), + "http://dummy.url")); } } diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestConnectorTest.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestConnectorTest.java index 083c879c5..0d90c6af4 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestConnectorTest.java +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/src/org/eclipse/mylyn/internal/bugzilla/rest/core/tests/BugzillaRestConnectorTest.java @@ -1,6 +1,12 @@ package org.eclipse.mylyn.internal.bugzilla.rest.core.tests; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; + +import java.util.concurrent.TimeUnit; import org.eclipse.mylyn.commons.net.AuthenticationCredentials; import org.eclipse.mylyn.commons.net.AuthenticationType; @@ -8,6 +14,7 @@ import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner; import org.eclipse.mylyn.commons.sdk.util.Junit4TestFixtureRunner.FixtureDefinition; import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConfiguration; import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConnector; +import org.eclipse.mylyn.internal.bugzilla.rest.core.Duration; import org.eclipse.mylyn.internal.bugzilla.rest.test.support.BugzillaRestTestFixture; import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager; import org.eclipse.mylyn.tasks.core.TaskRepository; @@ -15,6 +22,10 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; + @RunWith(Junit4TestFixtureRunner.class) @FixtureDefinition(fixtureClass = BugzillaRestTestFixture.class, fixtureType = "bugzillaREST") public class BugzillaRestConnectorTest { @@ -24,6 +35,8 @@ public class BugzillaRestConnectorTest { private BugzillaRestConnector connector; + private BugzillaRestConfiguration configuration; + public BugzillaRestConnectorTest(BugzillaRestTestFixture fixture) { this.actualFixture = fixture; } @@ -34,6 +47,49 @@ public class BugzillaRestConnectorTest { } @Test + public void testReloadCache() throws Exception { + connector = new BugzillaRestConnectorLocal(new Duration(5, TimeUnit.SECONDS)); + assertNotNull(connector); + System.out.println(new java.util.Date().toString()); + configuration = connector.getRepositoryConfiguration(actualFixture.repository()); + System.out.println(new java.util.Date().toString()); + assertNotNull(configuration); + Thread.sleep(6000L); + System.out.println(new java.util.Date().toString()); + BugzillaRestConfiguration configuration_new = connector.getRepositoryConfiguration(actualFixture.repository()); + System.out.println("after configuration_new"); + System.out.println(new java.util.Date().toString()); + assertEquals(configuration, configuration_new); + mySync = this; + synchronized (mySync) { + try { + mySync.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + mySync = null; + + System.out.println("after configuration reload"); + System.out.println(new java.util.Date().toString()); + BugzillaRestConfiguration configuration_new1 = connector.getRepositoryConfiguration(actualFixture.repository()); + System.out.println(new java.util.Date().toString()); + assertThat(configuration, not(configuration_new1)); + } + + @Test + public void testLoadCache() throws Exception { + BugzillaRestConfiguration configuration = connector.getRepositoryConfiguration(actualFixture.repository()); + assertNotNull(configuration); + Thread.sleep(7000L); + BugzillaRestConfiguration configuration_new = connector.getRepositoryConfiguration(actualFixture.repository()); + assertEquals(configuration, configuration_new); + Thread.sleep(4000L); + BugzillaRestConfiguration configuration_new1 = connector.getRepositoryConfiguration(actualFixture.repository()); + assertEquals(configuration, configuration_new1); + } + + @Test public void testLoadCacheWrongRepository() throws Exception { TaskRepository taskRepository = new TaskRepository(connector.getConnectorKind(), "http://mylyn.org/bugzilla-rest-trunk-wrong/"); @@ -43,4 +99,29 @@ public class BugzillaRestConnectorTest { assertNull(configuration); } + BugzillaRestConnectorTest mySync; + + class BugzillaRestConnectorLocal extends BugzillaRestConnector { + + public BugzillaRestConnectorLocal(Duration refreshAfterWriteDuration) { + super(refreshAfterWriteDuration); + } + + @Override + protected CacheBuilder<Object, Object> createCacheBuilder(Duration expireAfterWriteDuration, + Duration refreshAfterWriteDuration) { + return super.createCacheBuilder(expireAfterWriteDuration, refreshAfterWriteDuration).removalListener( + new RemovalListener<Object, Object>() { + @Override + public void onRemoval(RemovalNotification<Object, Object> notification) { + if (mySync != null) { + synchronized (mySync) { + mySync.notify(); + } + } + } + }); + } + } + } diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/4.5.6+/configuration.json b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/4.5.6+/configuration.json new file mode 100644 index 000000000..b068a7c31 --- /dev/null +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/4.5.6+/configuration.json @@ -0,0 +1 @@ +{"repositoryId":"http://dummy.url","fields":{"bug_id":{"id":1,"type":0,"is_custom":false,"name":"bug_id","display_name":"Bug #","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"short_desc":{"id":2,"type":0,"is_custom":false,"name":"short_desc","display_name":"Summary","is_mandatory":true,"is_on_bug_entry":false,"visibility_values":[]},"classification":{"id":3,"type":2,"is_custom":false,"name":"classification","display_name":"Classification","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"Unclassified","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false}]},"cf_freetext":{"id":60,"type":1,"is_custom":true,"name":"cf_freetext","display_name":"free text custom field","is_mandatory":false,"is_on_bug_entry":true,"visibility_values":[]},"product":{"id":4,"type":2,"is_custom":false,"name":"product","display_name":"Product","is_mandatory":true,"is_on_bug_entry":false,"visibility_values":[]},"cf_dropdown":{"id":61,"type":2,"is_custom":true,"name":"cf_dropdown","display_name":"drop down custom field","is_mandatory":false,"is_on_bug_entry":true,"visibility_values":[],"values":[{"name":"---","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false},{"name":"one","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false},{"name":"three","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false},{"name":"two","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false}]},"version":{"id":5,"type":0,"is_custom":false,"name":"version","display_name":"Version","is_mandatory":true,"is_on_bug_entry":false,"visibility_values":[],"value_field":"product","values":[{"name":"unspecified","sort_key":0,"visibility_values":["TestProduct"],"is_active":true,"is_open":false},{"name":"unspecified","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"a","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"b","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"c","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"unspecified","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"R1","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"R1.1","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"R2.0","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false}]},"cf_largetextbox":{"id":62,"type":4,"is_custom":true,"name":"cf_largetextbox","display_name":"large text box custom field","is_mandatory":false,"is_on_bug_entry":true,"visibility_values":[]},"rep_platform":{"id":6,"type":2,"is_custom":false,"name":"rep_platform","display_name":"Platform","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"All","sort_key":100,"visibility_values":[],"is_active":false,"is_open":false},{"name":"PC","sort_key":200,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Macintosh","sort_key":300,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Other","sort_key":400,"visibility_values":[],"is_active":false,"is_open":false}]},"cf_multiselect":{"id":63,"type":3,"is_custom":true,"name":"cf_multiselect","display_name":"multi selection box custom field","is_mandatory":false,"is_on_bug_entry":true,"visibility_values":[],"values":[{"name":"Blue","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Green","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Red","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Yellow","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false}]},"bug_file_loc":{"id":7,"type":0,"is_custom":false,"name":"bug_file_loc","display_name":"URL","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"cf_datetime":{"id":64,"type":5,"is_custom":true,"name":"cf_datetime","display_name":"date time custom field","is_mandatory":false,"is_on_bug_entry":true,"visibility_values":[]},"op_sys":{"id":8,"type":2,"is_custom":false,"name":"op_sys","display_name":"OS/Version","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"All","sort_key":100,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Windows","sort_key":200,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Mac OS","sort_key":300,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Linux","sort_key":400,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Other","sort_key":500,"visibility_values":[],"is_active":false,"is_open":false}]},"cf_bugid":{"id":65,"type":6,"is_custom":true,"name":"cf_bugid","display_name":"bug id custom field","is_mandatory":false,"is_on_bug_entry":true,"visibility_values":[]},"bug_status":{"id":9,"type":2,"is_custom":false,"name":"bug_status","display_name":"Status","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"sort_key":0,"visibility_values":[],"is_active":false,"is_open":true,"can_change_to":[{"name":"UNCONFIRMED","comment_required":false},{"name":"CONFIRMED","comment_required":false},{"name":"IN_PROGRESS","comment_required":false}]},{"name":"UNCONFIRMED","sort_key":100,"visibility_values":[],"is_active":false,"is_open":true,"can_change_to":[{"name":"CONFIRMED","comment_required":false},{"name":"IN_PROGRESS","comment_required":false},{"name":"RESOLVED","comment_required":false}]},{"name":"CONFIRMED","sort_key":200,"visibility_values":[],"is_active":false,"is_open":true,"can_change_to":[{"name":"IN_PROGRESS","comment_required":false},{"name":"RESOLVED","comment_required":false}]},{"name":"IN_PROGRESS","sort_key":300,"visibility_values":[],"is_active":false,"is_open":true,"can_change_to":[{"name":"CONFIRMED","comment_required":false},{"name":"RESOLVED","comment_required":false}]},{"name":"RESOLVED","sort_key":400,"visibility_values":[],"is_active":false,"is_open":false,"can_change_to":[{"name":"UNCONFIRMED","comment_required":false},{"name":"CONFIRMED","comment_required":false},{"name":"VERIFIED","comment_required":false}]},{"name":"VERIFIED","sort_key":500,"visibility_values":[],"is_active":false,"is_open":false,"can_change_to":[{"name":"UNCONFIRMED","comment_required":false},{"name":"CONFIRMED","comment_required":false}]}]},"status_whiteboard":{"id":10,"type":0,"is_custom":false,"name":"status_whiteboard","display_name":"Status Whiteboard","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"keywords":{"id":11,"type":8,"is_custom":false,"name":"keywords","display_name":"Keywords","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"Keyword1","sort_key":0,"is_active":false,"description":"1","is_open":false},{"name":"Keyword2","sort_key":0,"is_active":false,"description":"2","is_open":false}]},"resolution":{"id":12,"type":2,"is_custom":false,"name":"resolution","display_name":"Resolution","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"","sort_key":100,"visibility_values":[],"is_active":false,"is_open":false},{"name":"FIXED","sort_key":200,"visibility_values":[],"is_active":false,"is_open":false},{"name":"INVALID","sort_key":300,"visibility_values":[],"is_active":false,"is_open":false},{"name":"WONTFIX","sort_key":400,"visibility_values":[],"is_active":false,"is_open":false},{"name":"DUPLICATE","sort_key":500,"visibility_values":[],"is_active":false,"is_open":false},{"name":"WORKSFORME","sort_key":600,"visibility_values":[],"is_active":false,"is_open":false}]},"bug_severity":{"id":13,"type":2,"is_custom":false,"name":"bug_severity","display_name":"Severity","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"blocker","sort_key":100,"visibility_values":[],"is_active":false,"is_open":false},{"name":"critical","sort_key":200,"visibility_values":[],"is_active":false,"is_open":false},{"name":"major","sort_key":300,"visibility_values":[],"is_active":false,"is_open":false},{"name":"normal","sort_key":400,"visibility_values":[],"is_active":false,"is_open":false},{"name":"minor","sort_key":500,"visibility_values":[],"is_active":false,"is_open":false},{"name":"trivial","sort_key":600,"visibility_values":[],"is_active":false,"is_open":false},{"name":"enhancement","sort_key":700,"visibility_values":[],"is_active":false,"is_open":false}]},"priority":{"id":14,"type":2,"is_custom":false,"name":"priority","display_name":"Priority","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"Highest","sort_key":100,"visibility_values":[],"is_active":false,"is_open":false},{"name":"High","sort_key":200,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Normal","sort_key":300,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Low","sort_key":400,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Lowest","sort_key":500,"visibility_values":[],"is_active":false,"is_open":false},{"name":"---","sort_key":600,"visibility_values":[],"is_active":false,"is_open":false}]},"component":{"id":15,"type":2,"is_custom":false,"name":"component","display_name":"Component","is_mandatory":true,"is_on_bug_entry":false,"visibility_values":[],"value_field":"product","values":[{"name":"TestComponent","sort_key":0,"visibility_values":["TestProduct"],"is_active":true,"is_open":false},{"name":"Component 1","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"Component 2","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"ManualC1","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"ManualC2","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false}]},"assigned_to":{"id":16,"type":0,"is_custom":false,"name":"assigned_to","display_name":"AssignedTo","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"reporter":{"id":17,"type":0,"is_custom":false,"name":"reporter","display_name":"ReportedBy","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"qa_contact":{"id":18,"type":0,"is_custom":false,"name":"qa_contact","display_name":"QAContact","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"assigned_to_realname":{"id":19,"type":0,"is_custom":false,"name":"assigned_to_realname","display_name":"AssignedToName","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"reporter_realname":{"id":20,"type":0,"is_custom":false,"name":"reporter_realname","display_name":"ReportedByName","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"qa_contact_realname":{"id":21,"type":0,"is_custom":false,"name":"qa_contact_realname","display_name":"QAContactName","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"cc":{"id":22,"type":0,"is_custom":false,"name":"cc","display_name":"CC","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"dependson":{"id":23,"type":0,"is_custom":false,"name":"dependson","display_name":"Depends on","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"blocked":{"id":24,"type":0,"is_custom":false,"name":"blocked","display_name":"Blocks","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.description":{"id":25,"type":0,"is_custom":false,"name":"attachments.description","display_name":"Attachment description","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.filename":{"id":26,"type":0,"is_custom":false,"name":"attachments.filename","display_name":"Attachment filename","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.mimetype":{"id":27,"type":0,"is_custom":false,"name":"attachments.mimetype","display_name":"Attachment mime type","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.ispatch":{"id":28,"type":0,"is_custom":false,"name":"attachments.ispatch","display_name":"Attachment is patch","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.isobsolete":{"id":29,"type":0,"is_custom":false,"name":"attachments.isobsolete","display_name":"Attachment is obsolete","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.isprivate":{"id":30,"type":0,"is_custom":false,"name":"attachments.isprivate","display_name":"Attachment is private","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.submitter":{"id":31,"type":0,"is_custom":false,"name":"attachments.submitter","display_name":"Attachment creator","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"target_milestone":{"id":32,"type":0,"is_custom":false,"name":"target_milestone","display_name":"Target Milestone","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"value_field":"product","values":[{"name":"---","sort_key":0,"visibility_values":["TestProduct"],"is_active":true,"is_open":false},{"name":"---","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"---","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"M1","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"M1.0","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"M2","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"M2.0","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"M3","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"M3.0","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false}]},"creation_ts":{"id":33,"type":0,"is_custom":false,"name":"creation_ts","display_name":"Creation date","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"delta_ts":{"id":34,"type":0,"is_custom":false,"name":"delta_ts","display_name":"Last changed date","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"longdesc":{"id":35,"type":0,"is_custom":false,"name":"longdesc","display_name":"Comment","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"longdescs.isprivate":{"id":36,"type":0,"is_custom":false,"name":"longdescs.isprivate","display_name":"Comment is private","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"longdescs.count":{"id":37,"type":0,"is_custom":false,"name":"longdescs.count","display_name":"Number of Comments","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"alias":{"id":38,"type":0,"is_custom":false,"name":"alias","display_name":"Alias","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"everconfirmed":{"id":39,"type":0,"is_custom":false,"name":"everconfirmed","display_name":"Ever Confirmed","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"reporter_accessible":{"id":40,"type":0,"is_custom":false,"name":"reporter_accessible","display_name":"Reporter Accessible","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"cclist_accessible":{"id":41,"type":0,"is_custom":false,"name":"cclist_accessible","display_name":"CC Accessible","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"bug_group":{"id":42,"type":0,"is_custom":false,"name":"bug_group","display_name":"Group","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"estimated_time":{"id":43,"type":0,"is_custom":false,"name":"estimated_time","display_name":"Estimated Hours","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"remaining_time":{"id":44,"type":0,"is_custom":false,"name":"remaining_time","display_name":"Remaining Hours","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"deadline":{"id":45,"type":5,"is_custom":false,"name":"deadline","display_name":"Deadline","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"commenter":{"id":46,"type":0,"is_custom":false,"name":"commenter","display_name":"Commenter","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"flagtypes.name":{"id":47,"type":0,"is_custom":false,"name":"flagtypes.name","display_name":"Flags","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"requestees.login_name":{"id":48,"type":0,"is_custom":false,"name":"requestees.login_name","display_name":"Flag Requestee","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"setters.login_name":{"id":49,"type":0,"is_custom":false,"name":"setters.login_name","display_name":"Flag Setter","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"work_time":{"id":50,"type":0,"is_custom":false,"name":"work_time","display_name":"Hours Worked","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"percentage_complete":{"id":51,"type":0,"is_custom":false,"name":"percentage_complete","display_name":"Percentage Complete","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"content":{"id":52,"type":0,"is_custom":false,"name":"content","display_name":"Content","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attach_data.thedata":{"id":53,"type":0,"is_custom":false,"name":"attach_data.thedata","display_name":"Attachment data","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"owner_idle_time":{"id":54,"type":0,"is_custom":false,"name":"owner_idle_time","display_name":"Time Since Assignee Touched","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"see_also":{"id":55,"type":7,"is_custom":false,"name":"see_also","display_name":"See Also","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"tag":{"id":56,"type":8,"is_custom":false,"name":"tag","display_name":"Personal Tags","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"last_visit_ts":{"id":57,"type":5,"is_custom":false,"name":"last_visit_ts","display_name":"Last Visit","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"comment_tag":{"id":58,"type":0,"is_custom":false,"name":"comment_tag","display_name":"Comment Tag","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"days_elapsed":{"id":59,"type":0,"is_custom":false,"name":"days_elapsed","display_name":"Days since bug changed","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]}}}
\ No newline at end of file diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/4.5.6+/fieldName.json b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/4.5.6+/fieldName.json new file mode 100644 index 000000000..6601d5d3a --- /dev/null +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/4.5.6+/fieldName.json @@ -0,0 +1 @@ +["alias","assigned_to","assigned_to_realname","attach_data.thedata","attachments.description","attachments.filename","attachments.isobsolete","attachments.ispatch","attachments.isprivate","attachments.mimetype","attachments.submitter","blocked","bug_file_loc","bug_group","bug_id","bug_severity","bug_status","cc","cclist_accessible","cf_bugid","cf_datetime","cf_dropdown","cf_freetext","cf_largetextbox","cf_multiselect","classification","comment_tag","commenter","component","content","creation_ts","days_elapsed","deadline","delta_ts","dependson","estimated_time","everconfirmed","flagtypes.name","keywords","last_visit_ts","longdesc","longdescs.count","longdescs.isprivate","op_sys","owner_idle_time","percentage_complete","priority","product","qa_contact","qa_contact_realname","remaining_time","rep_platform","reporter","reporter_accessible","reporter_realname","requestees.login_name","resolution","see_also","setters.login_name","short_desc","status_whiteboard","tag","target_milestone","version","work_time"]
\ No newline at end of file diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/4.5.6+/fields.json b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/4.5.6+/fields.json new file mode 100644 index 000000000..a7a73b333 --- /dev/null +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core.tests/testdata/4.5.6+/fields.json @@ -0,0 +1 @@ +{"bug_id":{"id":1,"type":0,"is_custom":false,"name":"bug_id","display_name":"Bug #","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"short_desc":{"id":2,"type":0,"is_custom":false,"name":"short_desc","display_name":"Summary","is_mandatory":true,"is_on_bug_entry":false,"visibility_values":[]},"classification":{"id":3,"type":2,"is_custom":false,"name":"classification","display_name":"Classification","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"Unclassified","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false}]},"cf_freetext":{"id":60,"type":1,"is_custom":true,"name":"cf_freetext","display_name":"free text custom field","is_mandatory":false,"is_on_bug_entry":true,"visibility_values":[]},"product":{"id":4,"type":2,"is_custom":false,"name":"product","display_name":"Product","is_mandatory":true,"is_on_bug_entry":false,"visibility_values":[]},"cf_dropdown":{"id":61,"type":2,"is_custom":true,"name":"cf_dropdown","display_name":"drop down custom field","is_mandatory":false,"is_on_bug_entry":true,"visibility_values":[],"values":[{"name":"---","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false},{"name":"one","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false},{"name":"three","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false},{"name":"two","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false}]},"version":{"id":5,"type":0,"is_custom":false,"name":"version","display_name":"Version","is_mandatory":true,"is_on_bug_entry":false,"visibility_values":[],"value_field":"product","values":[{"name":"unspecified","sort_key":0,"visibility_values":["TestProduct"],"is_active":true,"is_open":false},{"name":"unspecified","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"a","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"b","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"c","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"unspecified","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"R1","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"R1.1","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"R2.0","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false}]},"cf_largetextbox":{"id":62,"type":4,"is_custom":true,"name":"cf_largetextbox","display_name":"large text box custom field","is_mandatory":false,"is_on_bug_entry":true,"visibility_values":[]},"rep_platform":{"id":6,"type":2,"is_custom":false,"name":"rep_platform","display_name":"Platform","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"All","sort_key":100,"visibility_values":[],"is_active":false,"is_open":false},{"name":"PC","sort_key":200,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Macintosh","sort_key":300,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Other","sort_key":400,"visibility_values":[],"is_active":false,"is_open":false}]},"cf_multiselect":{"id":63,"type":3,"is_custom":true,"name":"cf_multiselect","display_name":"multi selection box custom field","is_mandatory":false,"is_on_bug_entry":true,"visibility_values":[],"values":[{"name":"Blue","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Green","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Red","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Yellow","sort_key":0,"visibility_values":[],"is_active":false,"is_open":false}]},"bug_file_loc":{"id":7,"type":0,"is_custom":false,"name":"bug_file_loc","display_name":"URL","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"cf_datetime":{"id":64,"type":5,"is_custom":true,"name":"cf_datetime","display_name":"date time custom field","is_mandatory":false,"is_on_bug_entry":true,"visibility_values":[]},"op_sys":{"id":8,"type":2,"is_custom":false,"name":"op_sys","display_name":"OS/Version","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"All","sort_key":100,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Windows","sort_key":200,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Mac OS","sort_key":300,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Linux","sort_key":400,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Other","sort_key":500,"visibility_values":[],"is_active":false,"is_open":false}]},"cf_bugid":{"id":65,"type":6,"is_custom":true,"name":"cf_bugid","display_name":"bug id custom field","is_mandatory":false,"is_on_bug_entry":true,"visibility_values":[]},"bug_status":{"id":9,"type":2,"is_custom":false,"name":"bug_status","display_name":"Status","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"sort_key":0,"visibility_values":[],"is_active":false,"is_open":true,"can_change_to":[{"name":"UNCONFIRMED","comment_required":false},{"name":"CONFIRMED","comment_required":false},{"name":"IN_PROGRESS","comment_required":false}]},{"name":"UNCONFIRMED","sort_key":100,"visibility_values":[],"is_active":false,"is_open":true,"can_change_to":[{"name":"CONFIRMED","comment_required":false},{"name":"IN_PROGRESS","comment_required":false},{"name":"RESOLVED","comment_required":false}]},{"name":"CONFIRMED","sort_key":200,"visibility_values":[],"is_active":false,"is_open":true,"can_change_to":[{"name":"IN_PROGRESS","comment_required":false},{"name":"RESOLVED","comment_required":false}]},{"name":"IN_PROGRESS","sort_key":300,"visibility_values":[],"is_active":false,"is_open":true,"can_change_to":[{"name":"CONFIRMED","comment_required":false},{"name":"RESOLVED","comment_required":false}]},{"name":"RESOLVED","sort_key":400,"visibility_values":[],"is_active":false,"is_open":false,"can_change_to":[{"name":"UNCONFIRMED","comment_required":false},{"name":"CONFIRMED","comment_required":false},{"name":"VERIFIED","comment_required":false}]},{"name":"VERIFIED","sort_key":500,"visibility_values":[],"is_active":false,"is_open":false,"can_change_to":[{"name":"UNCONFIRMED","comment_required":false},{"name":"CONFIRMED","comment_required":false}]}]},"status_whiteboard":{"id":10,"type":0,"is_custom":false,"name":"status_whiteboard","display_name":"Status Whiteboard","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"keywords":{"id":11,"type":8,"is_custom":false,"name":"keywords","display_name":"Keywords","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"Keyword1","sort_key":0,"is_active":false,"description":"1","is_open":false},{"name":"Keyword2","sort_key":0,"is_active":false,"description":"2","is_open":false}]},"resolution":{"id":12,"type":2,"is_custom":false,"name":"resolution","display_name":"Resolution","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"","sort_key":100,"visibility_values":[],"is_active":false,"is_open":false},{"name":"FIXED","sort_key":200,"visibility_values":[],"is_active":false,"is_open":false},{"name":"INVALID","sort_key":300,"visibility_values":[],"is_active":false,"is_open":false},{"name":"WONTFIX","sort_key":400,"visibility_values":[],"is_active":false,"is_open":false},{"name":"DUPLICATE","sort_key":500,"visibility_values":[],"is_active":false,"is_open":false},{"name":"WORKSFORME","sort_key":600,"visibility_values":[],"is_active":false,"is_open":false}]},"bug_severity":{"id":13,"type":2,"is_custom":false,"name":"bug_severity","display_name":"Severity","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"blocker","sort_key":100,"visibility_values":[],"is_active":false,"is_open":false},{"name":"critical","sort_key":200,"visibility_values":[],"is_active":false,"is_open":false},{"name":"major","sort_key":300,"visibility_values":[],"is_active":false,"is_open":false},{"name":"normal","sort_key":400,"visibility_values":[],"is_active":false,"is_open":false},{"name":"minor","sort_key":500,"visibility_values":[],"is_active":false,"is_open":false},{"name":"trivial","sort_key":600,"visibility_values":[],"is_active":false,"is_open":false},{"name":"enhancement","sort_key":700,"visibility_values":[],"is_active":false,"is_open":false}]},"priority":{"id":14,"type":2,"is_custom":false,"name":"priority","display_name":"Priority","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"values":[{"name":"Highest","sort_key":100,"visibility_values":[],"is_active":false,"is_open":false},{"name":"High","sort_key":200,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Normal","sort_key":300,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Low","sort_key":400,"visibility_values":[],"is_active":false,"is_open":false},{"name":"Lowest","sort_key":500,"visibility_values":[],"is_active":false,"is_open":false},{"name":"---","sort_key":600,"visibility_values":[],"is_active":false,"is_open":false}]},"component":{"id":15,"type":2,"is_custom":false,"name":"component","display_name":"Component","is_mandatory":true,"is_on_bug_entry":false,"visibility_values":[],"value_field":"product","values":[{"name":"TestComponent","sort_key":0,"visibility_values":["TestProduct"],"is_active":true,"is_open":false},{"name":"Component 1","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"Component 2","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"ManualC1","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"ManualC2","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false}]},"assigned_to":{"id":16,"type":0,"is_custom":false,"name":"assigned_to","display_name":"AssignedTo","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"reporter":{"id":17,"type":0,"is_custom":false,"name":"reporter","display_name":"ReportedBy","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"qa_contact":{"id":18,"type":0,"is_custom":false,"name":"qa_contact","display_name":"QAContact","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"assigned_to_realname":{"id":19,"type":0,"is_custom":false,"name":"assigned_to_realname","display_name":"AssignedToName","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"reporter_realname":{"id":20,"type":0,"is_custom":false,"name":"reporter_realname","display_name":"ReportedByName","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"qa_contact_realname":{"id":21,"type":0,"is_custom":false,"name":"qa_contact_realname","display_name":"QAContactName","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"cc":{"id":22,"type":0,"is_custom":false,"name":"cc","display_name":"CC","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"dependson":{"id":23,"type":0,"is_custom":false,"name":"dependson","display_name":"Depends on","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"blocked":{"id":24,"type":0,"is_custom":false,"name":"blocked","display_name":"Blocks","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.description":{"id":25,"type":0,"is_custom":false,"name":"attachments.description","display_name":"Attachment description","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.filename":{"id":26,"type":0,"is_custom":false,"name":"attachments.filename","display_name":"Attachment filename","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.mimetype":{"id":27,"type":0,"is_custom":false,"name":"attachments.mimetype","display_name":"Attachment mime type","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.ispatch":{"id":28,"type":0,"is_custom":false,"name":"attachments.ispatch","display_name":"Attachment is patch","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.isobsolete":{"id":29,"type":0,"is_custom":false,"name":"attachments.isobsolete","display_name":"Attachment is obsolete","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.isprivate":{"id":30,"type":0,"is_custom":false,"name":"attachments.isprivate","display_name":"Attachment is private","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attachments.submitter":{"id":31,"type":0,"is_custom":false,"name":"attachments.submitter","display_name":"Attachment creator","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"target_milestone":{"id":32,"type":0,"is_custom":false,"name":"target_milestone","display_name":"Target Milestone","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[],"value_field":"product","values":[{"name":"---","sort_key":0,"visibility_values":["TestProduct"],"is_active":true,"is_open":false},{"name":"---","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"---","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"M1","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"M1.0","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"M2","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"M2.0","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false},{"name":"M3","sort_key":0,"visibility_values":["ManualTest"],"is_active":true,"is_open":false},{"name":"M3.0","sort_key":0,"visibility_values":["Product with Spaces"],"is_active":true,"is_open":false}]},"creation_ts":{"id":33,"type":0,"is_custom":false,"name":"creation_ts","display_name":"Creation date","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"delta_ts":{"id":34,"type":0,"is_custom":false,"name":"delta_ts","display_name":"Last changed date","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"longdesc":{"id":35,"type":0,"is_custom":false,"name":"longdesc","display_name":"Comment","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"longdescs.isprivate":{"id":36,"type":0,"is_custom":false,"name":"longdescs.isprivate","display_name":"Comment is private","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"longdescs.count":{"id":37,"type":0,"is_custom":false,"name":"longdescs.count","display_name":"Number of Comments","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"alias":{"id":38,"type":0,"is_custom":false,"name":"alias","display_name":"Alias","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"everconfirmed":{"id":39,"type":0,"is_custom":false,"name":"everconfirmed","display_name":"Ever Confirmed","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"reporter_accessible":{"id":40,"type":0,"is_custom":false,"name":"reporter_accessible","display_name":"Reporter Accessible","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"cclist_accessible":{"id":41,"type":0,"is_custom":false,"name":"cclist_accessible","display_name":"CC Accessible","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"bug_group":{"id":42,"type":0,"is_custom":false,"name":"bug_group","display_name":"Group","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"estimated_time":{"id":43,"type":0,"is_custom":false,"name":"estimated_time","display_name":"Estimated Hours","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"remaining_time":{"id":44,"type":0,"is_custom":false,"name":"remaining_time","display_name":"Remaining Hours","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"deadline":{"id":45,"type":5,"is_custom":false,"name":"deadline","display_name":"Deadline","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"commenter":{"id":46,"type":0,"is_custom":false,"name":"commenter","display_name":"Commenter","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"flagtypes.name":{"id":47,"type":0,"is_custom":false,"name":"flagtypes.name","display_name":"Flags","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"requestees.login_name":{"id":48,"type":0,"is_custom":false,"name":"requestees.login_name","display_name":"Flag Requestee","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"setters.login_name":{"id":49,"type":0,"is_custom":false,"name":"setters.login_name","display_name":"Flag Setter","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"work_time":{"id":50,"type":0,"is_custom":false,"name":"work_time","display_name":"Hours Worked","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"percentage_complete":{"id":51,"type":0,"is_custom":false,"name":"percentage_complete","display_name":"Percentage Complete","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"content":{"id":52,"type":0,"is_custom":false,"name":"content","display_name":"Content","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"attach_data.thedata":{"id":53,"type":0,"is_custom":false,"name":"attach_data.thedata","display_name":"Attachment data","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"owner_idle_time":{"id":54,"type":0,"is_custom":false,"name":"owner_idle_time","display_name":"Time Since Assignee Touched","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"see_also":{"id":55,"type":7,"is_custom":false,"name":"see_also","display_name":"See Also","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"tag":{"id":56,"type":8,"is_custom":false,"name":"tag","display_name":"Personal Tags","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"last_visit_ts":{"id":57,"type":5,"is_custom":false,"name":"last_visit_ts","display_name":"Last Visit","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"comment_tag":{"id":58,"type":0,"is_custom":false,"name":"comment_tag","display_name":"Comment Tag","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]},"days_elapsed":{"id":59,"type":0,"is_custom":false,"name":"days_elapsed","display_name":"Days since bug changed","is_mandatory":false,"is_on_bug_entry":false,"visibility_values":[]}}
\ No newline at end of file diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/.settings/org.eclipse.jdt.core.prefs b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/.settings/org.eclipse.jdt.core.prefs index b6a001145..eaa9c19ea 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/.settings/org.eclipse.jdt.core.prefs +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/.settings/org.eclipse.jdt.core.prefs @@ -16,6 +16,7 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annota org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.6 @@ -39,7 +40,7 @@ org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning @@ -193,10 +194,8 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestAuthenticatedGetRequest.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestAuthenticatedGetRequest.java index e8c46b2d8..9c111ae97 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestAuthenticatedGetRequest.java +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestAuthenticatedGetRequest.java @@ -27,15 +27,21 @@ import org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationType; import org.eclipse.mylyn.commons.repositories.core.auth.UserCredentials; import org.eclipse.mylyn.commons.repositories.http.core.CommonHttpResponse; import org.eclipse.mylyn.commons.repositories.http.core.HttpUtil; -import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.BugzillaRestLoginToken; +import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.LoginToken; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; -public abstract class BugzillaRestAuthenticatedGetRequest<T> extends BugzillaRestRequest<T> { +public class BugzillaRestAuthenticatedGetRequest<T> extends BugzillaRestRequest<T> { - public BugzillaRestAuthenticatedGetRequest(BugzillaRestHttpClient client) { + private final String urlSuffix; + + private final TypeToken responseType; + + public BugzillaRestAuthenticatedGetRequest(BugzillaRestHttpClient client, String urlSuffix, TypeToken responseType) { super(client); + this.urlSuffix = urlSuffix; + this.responseType = responseType; } @Override @@ -57,11 +63,11 @@ public abstract class BugzillaRestAuthenticatedGetRequest<T> extends BugzillaRes new AuthenticationRequest<AuthenticationType<UserCredentials>>(getClient().getLocation(), AuthenticationType.REPOSITORY)); } else { - TypeToken<BugzillaRestLoginToken> type = new TypeToken<BugzillaRestLoginToken>() { + TypeToken<LoginToken> type = new TypeToken<LoginToken>() { }; InputStream is = response.getEntity().getContent(); InputStreamReader in = new InputStreamReader(is); - BugzillaRestLoginToken loginToken = new Gson().fromJson(in, type.getType()); + LoginToken loginToken = new Gson().fromJson(in, type.getType()); ((BugzillaRestHttpClient) getClient()).setLoginToken(loginToken); getClient().setAuthenticated(true); } @@ -73,7 +79,7 @@ public abstract class BugzillaRestAuthenticatedGetRequest<T> extends BugzillaRes @Override protected HttpRequestBase createHttpRequestBase() { String bugUrl = getUrlSuffix(); - BugzillaRestLoginToken token = ((BugzillaRestHttpClient) getClient()).getLoginToken(); + LoginToken token = ((BugzillaRestHttpClient) getClient()).getLoginToken(); if ((!(this instanceof BugzillaRestValidateRequest) && !(this instanceof BugzillaRestUnauthenticatedGetRequest)) && token != null && bugUrl.length() > 0) { if (!bugUrl.endsWith("?")) { @@ -97,4 +103,14 @@ public abstract class BugzillaRestAuthenticatedGetRequest<T> extends BugzillaRes return processAndRelease(response, monitor); } + @Override + protected T parseFromJson(InputStreamReader in) { + return new Gson().fromJson(in, responseType.getType()); + } + + @Override + protected String getUrlSuffix() { + return urlSuffix; + } + } diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestClient.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestClient.java index c52e3f5c7..bcb739795 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestClient.java +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestClient.java @@ -11,11 +11,25 @@ package org.eclipse.mylyn.internal.bugzilla.rest.core; +import java.util.Map; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.mylyn.commons.core.StatusHandler; import org.eclipse.mylyn.commons.core.operations.IOperationMonitor; import org.eclipse.mylyn.commons.repositories.core.RepositoryLocation; -import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.BugzillaRestErrorResponse; +import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.ErrorResponse; +import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.Field; +import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.FieldResponse; +import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.Named; +import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.VersionResponse; import org.eclipse.mylyn.tasks.core.TaskRepository; +import com.google.common.base.Function; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.gson.reflect.TypeToken; + public class BugzillaRestClient { private final BugzillaRestHttpClient client; @@ -29,16 +43,48 @@ public class BugzillaRestClient { } public BugzillaRestVersion getVersion(IOperationMonitor monitor) throws BugzillaRestException { - return new BugzillaRestRequestGetVersion(client).run(monitor); + + VersionResponse versionResponse = new BugzillaRestUnauthenticatedGetRequest<VersionResponse>(client, + "/version", new TypeToken<VersionResponse>() { + }).run(monitor); + return new BugzillaRestVersion(versionResponse.getVersion()); } public boolean validate(IOperationMonitor monitor) throws BugzillaRestException { - BugzillaRestErrorResponse validateResponse = new BugzillaRestValidateRequest(client).run(monitor); + ErrorResponse validateResponse = new BugzillaRestValidateRequest(client).run(monitor); return validateResponse.isError() && validateResponse.getCode() == 32614; } public BugzillaRestConfiguration getConfiguration(TaskRepository repository, IOperationMonitor monitor) { - return null; + try { + BugzillaRestConfiguration config = new BugzillaRestConfiguration(repository.getUrl()); + config.setFields(getFields(monitor)); + return config; + } catch (Exception e) { + StatusHandler.log(new Status(IStatus.ERROR, BugzillaRestCore.ID_PLUGIN, + "Could not get the Configuration", e)); //$NON-NLS-1$ + return null; + } + } + + public <R, E extends Named> Map<String, E> retrieveItems(IOperationMonitor monitor, String path, + Function<R, E[]> attributeProvider, TypeToken typeToken) throws BugzillaRestException { + R response = new BugzillaRestAuthenticatedGetRequest<R>(client, path, typeToken).run(monitor); + E[] members = attributeProvider.apply(response); + return Maps.uniqueIndex(Lists.newArrayList(members), new Function<E, String>() { + public String apply(E input) { + return input.getName(); + }; + }); + } + + public Map<String, Field> getFields(IOperationMonitor monitor) throws BugzillaRestException { + return retrieveItems(monitor, "/field/bug?", new Function<FieldResponse, Field[]>() { + public Field[] apply(FieldResponse input) { + return input.getFields(); + } + }, new TypeToken<FieldResponse>() { + }); } } diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java index f765edfba..5e954326a 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestConfiguration.java @@ -12,19 +12,36 @@ package org.eclipse.mylyn.internal.bugzilla.rest.core; import java.io.Serializable; +import java.util.Map; + +import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.Field; public class BugzillaRestConfiguration implements Serializable { - private static final long serialVersionUID = 3433667217913466746L; + private static final long serialVersionUID = -4658602653003624954L; + + private final String repositoryId; + + private Map<String, Field> fields; + + public BugzillaRestConfiguration(String repositoryId) { + this.repositoryId = repositoryId; + } + + public String getRepositoryId() { + return repositoryId; + } - private final String url; + void setFields(Map<String, Field> fields) { + this.fields = fields; + } - public BugzillaRestConfiguration(String url) { - this.url = url; + public Map<String, Field> getFields() { + return fields; } - public String getUrl() { - return url; + public Field getFieldWithName(String fieldName) { + return fields.get(fieldName); } } diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestHttpClient.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestHttpClient.java index 0e497f9dd..86bc5109b 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestHttpClient.java +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestHttpClient.java @@ -13,20 +13,20 @@ package org.eclipse.mylyn.internal.bugzilla.rest.core; import org.eclipse.mylyn.commons.repositories.core.RepositoryLocation; import org.eclipse.mylyn.commons.repositories.http.core.CommonHttpClient; -import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.BugzillaRestLoginToken; +import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.LoginToken; public class BugzillaRestHttpClient extends CommonHttpClient { - private BugzillaRestLoginToken loginToken = null; + private LoginToken loginToken = null; public BugzillaRestHttpClient(RepositoryLocation location) { super(location); } - public BugzillaRestLoginToken getLoginToken() { + public LoginToken getLoginToken() { return loginToken; } - public void setLoginToken(BugzillaRestLoginToken loginToken) { + public void setLoginToken(LoginToken loginToken) { this.loginToken = loginToken; } diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestRequestGetVersion.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestRequestGetVersion.java deleted file mode 100644 index ce7fa08b3..000000000 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestRequestGetVersion.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 Frank Becker and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Frank Becker - initial API and implementation - *******************************************************************************/ - -package org.eclipse.mylyn.internal.bugzilla.rest.core; - -import java.io.InputStreamReader; - -import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.BugzillaRestVersionResponse; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -public class BugzillaRestRequestGetVersion extends BugzillaRestUnauthenticatedGetRequest<BugzillaRestVersion> { - - public BugzillaRestRequestGetVersion(BugzillaRestHttpClient client) { - super(client); - } - - @Override - protected String getUrlSuffix() { - return "/version"; //$NON-NLS-1$ - } - - @Override - protected BugzillaRestVersion parseFromJson(InputStreamReader in) { - TypeToken<BugzillaRestVersionResponse> type = new TypeToken<BugzillaRestVersionResponse>() { - }; - BugzillaRestVersionResponse versionResponse = new Gson().fromJson(in, type.getType()); - return new BugzillaRestVersion(versionResponse.getVersion()); - } - -} diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestUnauthenticatedGetRequest.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestUnauthenticatedGetRequest.java index 3c3213b52..d1afb2803 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestUnauthenticatedGetRequest.java +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestUnauthenticatedGetRequest.java @@ -11,10 +11,12 @@ package org.eclipse.mylyn.internal.bugzilla.rest.core; -public abstract class BugzillaRestUnauthenticatedGetRequest<T> extends BugzillaRestAuthenticatedGetRequest<T> { +import com.google.gson.reflect.TypeToken; - public BugzillaRestUnauthenticatedGetRequest(BugzillaRestHttpClient client) { - super(client); +public class BugzillaRestUnauthenticatedGetRequest<T> extends BugzillaRestAuthenticatedGetRequest<T> { + + public BugzillaRestUnauthenticatedGetRequest(BugzillaRestHttpClient client, String urlSuffix, TypeToken responseType) { + super(client, urlSuffix, responseType); } @Override diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestValidateRequest.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestValidateRequest.java index 795bf4e32..407b32244 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestValidateRequest.java +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/BugzillaRestValidateRequest.java @@ -12,20 +12,19 @@ package org.eclipse.mylyn.internal.bugzilla.rest.core; import java.io.IOException; -import java.io.InputStreamReader; import org.apache.http.HttpStatus; import org.eclipse.mylyn.commons.core.operations.IOperationMonitor; import org.eclipse.mylyn.commons.repositories.http.core.CommonHttpResponse; -import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.BugzillaRestErrorResponse; +import org.eclipse.mylyn.internal.bugzilla.rest.core.response.data.ErrorResponse; -import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; -public class BugzillaRestValidateRequest extends BugzillaRestAuthenticatedGetRequest<BugzillaRestErrorResponse> { +public class BugzillaRestValidateRequest extends BugzillaRestAuthenticatedGetRequest<ErrorResponse> { public BugzillaRestValidateRequest(BugzillaRestHttpClient client) { - super(client); + super(client, "", new TypeToken<ErrorResponse>() { + }); } @Override @@ -37,11 +36,4 @@ public class BugzillaRestValidateRequest extends BugzillaRestAuthenticatedGetReq : HttpStatus.SC_BAD_REQUEST, monitor); } - @Override - protected BugzillaRestErrorResponse parseFromJson(InputStreamReader in) { - TypeToken<BugzillaRestErrorResponse> type = new TypeToken<BugzillaRestErrorResponse>() { - }; - return new Gson().fromJson(in, type.getType()); - } - } diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/ListenableFutureJob.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/ListenableFutureJob.java index 5770e0264..138210a15 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/ListenableFutureJob.java +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/ListenableFutureJob.java @@ -108,4 +108,4 @@ public abstract class ListenableFutureJob<V> extends Job implements ListenableFu public void addListener(Runnable listener, Executor executor) { listeners.add(new Listener(listener, executor)); } -}
\ No newline at end of file +} diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/BugzillaRestErrorResponse.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/ErrorResponse.java index 3e467fe88..03fb6572b 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/BugzillaRestErrorResponse.java +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/ErrorResponse.java @@ -11,7 +11,7 @@ package org.eclipse.mylyn.internal.bugzilla.rest.core.response.data; -public class BugzillaRestErrorResponse { +public class ErrorResponse { private boolean error; private String message; diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Field.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Field.java new file mode 100644 index 000000000..de56aedbf --- /dev/null +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Field.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2013 Frank Becker and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Frank Becker - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.internal.bugzilla.rest.core.response.data; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class Field implements Named, Serializable { + + private static final long serialVersionUID = -5578410875657273067L; + + private int id; + + private int type; + + @SerializedName("is_custom") + private boolean custom; + + private String name; + + @SerializedName("display_name") + private String displayName; + + @SerializedName("is_mandatory") + private boolean mandatory; + + @SerializedName("is_on_bug_entry") + private boolean onBugEntry; + + @SerializedName("visibility_field") + private String visibilityField; + + @SerializedName("visibility_values") + private String[] visibilityValues; + + @SerializedName("value_field") + private String valueField; + + private FieldValues[] values; + + public int getId() { + return id; + } + + public int getType() { + return type; + } + + public boolean isCustom() { + return custom; + } + + @Override + public String getName() { + return name; + } + + public String getDisplayName() { + return displayName; + } + + public boolean isMandatory() { + return mandatory; + } + + public boolean isOnBugEntry() { + return onBugEntry; + } + + public String getVisibilityField() { + return visibilityField; + } + + public String[] getVisibilityValues() { + return visibilityValues; + } + + public String getValueField() { + return valueField; + } + + public FieldValues[] getValues() { + return values; + } + +}
\ No newline at end of file diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/FieldResponse.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/FieldResponse.java new file mode 100644 index 000000000..158a5871c --- /dev/null +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/FieldResponse.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2013 Frank Becker and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Frank Becker - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.internal.bugzilla.rest.core.response.data; + +public class FieldResponse { + private Field[] fields; + + public Field[] getFields() { + return fields; + } +} diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/FieldValues.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/FieldValues.java new file mode 100644 index 000000000..4f7af8bcc --- /dev/null +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/FieldValues.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2013 Frank Becker and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Frank Becker - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.internal.bugzilla.rest.core.response.data; + +import java.io.Serializable; + +public class FieldValues implements Serializable { + + private static final long serialVersionUID = -7596294082190197659L; + + private String name; + + private int sort_key; + + private String[] visibility_values; + + private boolean is_active; + + private String description; + + private boolean is_open; + + private StatusTransition[] can_change_to; + + public String getName() { + return name; + } + + public int getSortKey() { + return sort_key; + } + + public String[] getVisibilityValues() { + return visibility_values; + } + + public boolean isActive() { + return is_active; + } + + public String getDescription() { + return description; + } + + public boolean isOpen() { + return is_open; + } + + public StatusTransition[] getCanChangeTo() { + return can_change_to; + } + +}
\ No newline at end of file diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/BugzillaRestLoginToken.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/LoginToken.java index a8cbe0baa..d8a3c0e17 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/BugzillaRestLoginToken.java +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/LoginToken.java @@ -11,7 +11,7 @@ package org.eclipse.mylyn.internal.bugzilla.rest.core.response.data; -public class BugzillaRestLoginToken { +public class LoginToken { private String id; private String token; diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Named.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Named.java new file mode 100644 index 000000000..9dc53ebac --- /dev/null +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/Named.java @@ -0,0 +1,6 @@ +package org.eclipse.mylyn.internal.bugzilla.rest.core.response.data; + + +public interface Named { + public String getName(); +} diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/StatusTransition.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/StatusTransition.java new file mode 100644 index 000000000..dd711a8a3 --- /dev/null +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/StatusTransition.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2013 Frank Becker and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Frank Becker - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.internal.bugzilla.rest.core.response.data; + +import java.io.Serializable; + +public class StatusTransition implements Serializable { + + private static final long serialVersionUID = 791312498240951654L; + + public String name; + + public boolean comment_required; + + public String getName() { + return name; + } + + public boolean isCommentRequired() { + return comment_required; + } +}
\ No newline at end of file diff --git a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/BugzillaRestVersionResponse.java b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/VersionResponse.java index 8adf5eea6..d6c5732a8 100644 --- a/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/BugzillaRestVersionResponse.java +++ b/connector-bugzilla-rest/org.eclipse.mylyn.bugzilla.rest.core/src/org/eclipse/mylyn/internal/bugzilla/rest/core/response/data/VersionResponse.java @@ -11,7 +11,7 @@ package org.eclipse.mylyn.internal.bugzilla.rest.core.response.data; -public class BugzillaRestVersionResponse { +public class VersionResponse { private String version; |