Search in sources :

Example 1 with OSIORestGetAuthUser

use of org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestGetAuthUser in project linuxtools by eclipse.

the class TestOSIORestGetAuthUser method testGetAuthUser.

@Test
public void testGetAuthUser() throws Exception {
    TestData testData = new TestData();
    TestUtils.initSpaces(requestProvider, testData);
    OSIORestClient client = connector.getClient(repository, requestProvider);
    OSIORestConfiguration config = client.getConfiguration(repository, new NullOperationMonitor());
    config.setSpaces(testData.spaceMap);
    connector.setConfiguration(config);
    RepositoryLocation location = client.getClient().getLocation();
    location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_ID, "user");
    location.setProperty(IOSIORestConstants.REPOSITORY_AUTH_TOKEN, "xxxxxxTokenxxxxxx");
    OSIORestGetAuthUser data = new OSIORestGetAuthUser(client.getClient());
    String bundleLocation = Activator.getContext().getBundle().getLocation();
    int index = bundleLocation.indexOf('/');
    String fileName = bundleLocation.substring(index) + "/testjson/authuser.data";
    FileReader in = new FileReader(fileName);
    Identity user = data.testParseFromJson(in);
    assertEquals("User.org", user.getCompany());
    assertEquals("user@user.org", user.getEmail());
    assertEquals("User 1", user.getFullName());
    assertEquals("IDENTITY-0001", user.getIdentityID());
    assertEquals("https://www.gravatar.com/avatar/user.jpg", user.getImageURL());
    assertEquals("USER-0001", user.getUserID());
    assertEquals("user", user.getUsername());
    assertEquals("IDENTITY-0001", user.getId());
}
Also used : OSIORestGetAuthUser(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestGetAuthUser) TestData(org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData) OSIORestClient(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient) OSIORestConfiguration(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration) FileReader(java.io.FileReader) Identity(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Identity) RepositoryLocation(org.eclipse.mylyn.commons.repositories.core.RepositoryLocation) NullOperationMonitor(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.NullOperationMonitor) Test(org.junit.Test)

Aggregations

FileReader (java.io.FileReader)1 NullOperationMonitor (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.NullOperationMonitor)1 OSIORestClient (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestClient)1 OSIORestConfiguration (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConfiguration)1 OSIORestGetAuthUser (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestGetAuthUser)1 Identity (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.Identity)1 TestData (org.eclipse.linuxtools.mylyn.osio.rest.test.support.TestData)1 RepositoryLocation (org.eclipse.mylyn.commons.repositories.core.RepositoryLocation)1 Test (org.junit.Test)1