use of org.folio.rest.jaxrs.model.KbCredentials in project mod-kb-ebsco-java by folio-org.
the class EholdingsKbCredentialsImplTest method shouldReturn422OnPutWhenCredentialsNameIsEmpty.
@Test
public void shouldReturn422OnPutWhenCredentialsNameIsEmpty() {
KbCredentials creds = stubbedCredentials();
creds.getAttributes().setName("");
KbCredentialsPutRequest kbCredentialsPutRequest = new KbCredentialsPutRequest().withData(creds);
String putBody = Json.encode(kbCredentialsPutRequest);
String resourcePath = KB_CREDENTIALS_ENDPOINT + "/11111111-1111-1111-a111-111111111111";
JsonapiError error = putWithStatus(resourcePath, putBody, SC_UNPROCESSABLE_ENTITY, STUB_TOKEN_HEADER).as(JsonapiError.class);
assertErrorContainsTitle(error, "Invalid name");
assertErrorContainsDetail(error, "name must not be empty");
}
use of org.folio.rest.jaxrs.model.KbCredentials in project mod-kb-ebsco-java by folio-org.
the class EholdingsKbCredentialsImplTest method shouldReturn200AndKbCredentialsOnGetByUserWhenSingleKbCredentialsPresent.
@Test
public void shouldReturn200AndKbCredentialsOnGetByUserWhenSingleKbCredentialsPresent() {
saveKbCredentials(STUB_API_URL, STUB_CREDENTIALS_NAME, STUB_API_KEY, STUB_CUSTOMER_ID, vertx);
KbCredentials actual = getWithStatus(USER_KB_CREDENTIAL_ENDPOINT, SC_OK, STUB_TOKEN_HEADER).as(KbCredentials.class);
assertEquals(getKbCredentialsNonSecured(vertx).get(0), actual);
}
use of org.folio.rest.jaxrs.model.KbCredentials in project mod-kb-ebsco-java by folio-org.
the class EholdingsKbCredentialsImplTest method shouldReturn422OnPostWhenCredentialsNameIsLongerThen255.
@Test
public void shouldReturn422OnPostWhenCredentialsNameIsLongerThen255() {
KbCredentials creds = stubbedCredentials();
creds.getAttributes().setName(Strings.repeat('*', 256));
KbCredentialsPostRequest kbCredentialsPostRequest = new KbCredentialsPostRequest().withData(creds);
String postBody = Json.encode(kbCredentialsPostRequest);
JsonapiError error = postWithStatus(KB_CREDENTIALS_ENDPOINT, postBody, SC_UNPROCESSABLE_ENTITY, STUB_TOKEN_HEADER).as(JsonapiError.class);
assertErrorContainsTitle(error, "Invalid name");
assertErrorContainsDetail(error, "name is too long (maximum is 255 characters)");
}
use of org.folio.rest.jaxrs.model.KbCredentials in project mod-kb-ebsco-java by folio-org.
the class EholdingsKbCredentialsImplTest method shouldReturn204OnDeleteWhenCredentialsAreMissing.
@Test
public void shouldReturn204OnDeleteWhenCredentialsAreMissing() {
String resourcePath = KB_CREDENTIALS_ENDPOINT + "/11111111-1111-1111-a111-111111111111";
deleteWithNoContent(resourcePath);
List<KbCredentials> kbCredentialsInDb = getKbCredentials(vertx);
assertTrue(kbCredentialsInDb.isEmpty());
}
use of org.folio.rest.jaxrs.model.KbCredentials in project mod-kb-ebsco-java by folio-org.
the class EholdingsKbCredentialsImplTest method shouldReturn201OnPostIfCredentialsAreValid.
@Test
public void shouldReturn201OnPostIfCredentialsAreValid() {
KbCredentialsPostRequest kbCredentialsPostRequest = new KbCredentialsPostRequest().withData(stubbedCredentials());
String postBody = Json.encode(kbCredentialsPostRequest);
mockVerifyValidCredentialsRequest();
KbCredentials actual = postWithStatus(KB_CREDENTIALS_ENDPOINT, postBody, SC_CREATED, STUB_TOKEN_HEADER).as(KbCredentials.class);
assertNotNull(actual);
assertNotNull(actual.getId());
assertNotNull(actual.getType());
assertEquals(getWiremockUrl(), actual.getAttributes().getUrl());
assertEquals(STUB_CREDENTIALS_NAME, actual.getAttributes().getName());
assertEquals(STUB_CUSTOMER_ID, actual.getAttributes().getCustomerId());
assertEquals(STUB_USERNAME, actual.getMeta().getCreatedByUsername());
assertEquals(STUB_USER_ID, actual.getMeta().getCreatedByUserId());
assertNotNull(actual.getMeta().getCreatedDate());
}
Aggregations