use of org.gluu.model.passport.Provider in project oxTrust by GluuFederation.
the class PassportProviderWebResourceTest method createProviderTest.
@Test
public void createProviderTest() {
String name = "ApiLinkedin";
Provider provider = getProvider(name);
HttpPost request = new HttpPost(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.PASSPORT + ApiConstants.PROVIDERS);
try {
HttpEntity entity = new ByteArrayEntity(mapper.writeValueAsString(provider).toString().getBytes("UTF-8"), ContentType.APPLICATION_FORM_URLENCODED);
request.setEntity(entity);
request.setHeader(CONTENT_TYPE, MediaType.APPLICATION_JSON);
HttpResponse response = handle(request);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
HttpEntity result = response.getEntity();
Provider myProvider = mapper.readValue(EntityUtils.toString(result), Provider.class);
Assert.assertEquals(myProvider.getDisplayName(), name);
Assert.assertEquals(myProvider.isEnabled(), false);
} catch (ParseException | IOException e) {
e.printStackTrace();
Assert.assertTrue(false);
}
}
Aggregations