use of org.folio.rest.jaxrs.model.KbCredentialsPostRequest in project mod-kb-ebsco-java by folio-org.
the class EholdingsKbCredentialsImplTest method shouldReturn422OnPostWhenCredentialsAreInvalid.
@Test
public void shouldReturn422OnPostWhenCredentialsAreInvalid() {
KbCredentialsPostRequest kbCredentialsPostRequest = new KbCredentialsPostRequest().withData(stubbedCredentials());
String postBody = Json.encode(kbCredentialsPostRequest);
mockVerifyFailedCredentialsRequest();
JsonapiError error = postWithStatus(KB_CREDENTIALS_ENDPOINT, postBody, SC_UNPROCESSABLE_ENTITY, STUB_TOKEN_HEADER).as(JsonapiError.class);
assertErrorContainsTitle(error, "KB API Credentials are invalid");
}
use of org.folio.rest.jaxrs.model.KbCredentialsPostRequest 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.KbCredentialsPostRequest 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());
}
use of org.folio.rest.jaxrs.model.KbCredentialsPostRequest in project mod-kb-ebsco-java by folio-org.
the class EholdingsKbCredentialsImplTest method shouldReturnStatusNotStartedOnKbCredentialsCreation.
@Test
public void shouldReturnStatusNotStartedOnKbCredentialsCreation() {
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);
final HoldingsLoadingStatus status = getStatus(actual.getId(), vertx);
assertEquals(LoadStatusNameEnum.NOT_STARTED, status.getData().getAttributes().getStatus().getName());
final RetryStatus retryStatus = getRetryStatus(actual.getId(), vertx);
assertThat(retryStatus, notNullValue());
}
use of org.folio.rest.jaxrs.model.KbCredentialsPostRequest in project mod-kb-ebsco-java by folio-org.
the class EholdingsKbCredentialsImplTest method shouldReturn422OnPostWhenCredentialsNameIsEmpty.
@Test
public void shouldReturn422OnPostWhenCredentialsNameIsEmpty() {
KbCredentials creds = stubbedCredentials();
creds.getAttributes().setName("");
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 must not be empty");
}
Aggregations