use of org.folio.rest.jaxrs.model.KbCredentialsDataAttributes in project mod-kb-ebsco-java by folio-org.
the class KbCredentialsPatchRequestConverter method convert.
@Override
public KbCredentials convert(@NonNull KbCredentialsPatchRequest source) {
KbCredentialsPatchRequestData data = source.getData();
KbCredentialsPatchRequestDataAttributes attributes = data.getAttributes();
return new KbCredentials().withId(data.getId()).withAttributes(new KbCredentialsDataAttributes().withApiKey(attributes.getApiKey()).withCustomerId(attributes.getCustomerId()).withName(attributes.getName()).withUrl(attributes.getUrl()));
}
use of org.folio.rest.jaxrs.model.KbCredentialsDataAttributes in project mod-kb-ebsco-java by folio-org.
the class KbCredentialsServiceImpl method updatePartially.
@Override
public CompletableFuture<Void> updatePartially(String id, KbCredentialsPatchRequest entity, Map<String, String> okapiHeaders) {
KbCredentials patchRequestData = convertPatchToCredentials(entity);
patchBodyValidator.validate(patchRequestData);
KbCredentialsDataAttributes attributes = patchRequestData.getAttributes();
return prepareAndSave(fetchDbKbCredentials(id, okapiHeaders), (dbCredentials, userInfo) -> preparePartialUpdateEntity(dbCredentials, attributes, userInfo), okapiHeaders).thenApply(dbKbCredentials -> null);
}
use of org.folio.rest.jaxrs.model.KbCredentialsDataAttributes in project mod-kb-ebsco-java by folio-org.
the class KbCredentialsPatchBodyValidator method validate.
public void validate(KbCredentials patchRequest) {
KbCredentialsDataAttributes attributes = patchRequest.getAttributes();
ValidatorUtil.checkIsNotAllBlank("attributes", attributes.getApiKey(), attributes.getCustomerId(), attributes.getName(), attributes.getUrl());
if (attributes.getName() != null) {
validateName(attributes);
}
if (attributes.getApiKey() != null) {
validateApiKey(attributes);
}
if (attributes.getCustomerId() != null) {
validateCustomerId(attributes);
}
if (attributes.getUrl() != null) {
validateUrl(attributes);
}
}
use of org.folio.rest.jaxrs.model.KbCredentialsDataAttributes in project mod-kb-ebsco-java by folio-org.
the class KbCredentialsBodyAttributesValidatorTest method shouldThrowExceptionWhenNullUrl.
@Test
public void shouldThrowExceptionWhenNullUrl() {
expectedEx.expect(InputValidationException.class);
expectedEx.expectMessage("Invalid url");
KbCredentialsDataAttributes attributes = new KbCredentialsDataAttributes().withName("name").withApiKey("key").withCustomerId("custId");
validator.validateAttributes(attributes);
}
use of org.folio.rest.jaxrs.model.KbCredentialsDataAttributes in project mod-kb-ebsco-java by folio-org.
the class KbCredentialsBodyAttributesValidatorTest method shouldThrowExceptionWhenEmptyName.
@Test
public void shouldThrowExceptionWhenEmptyName() {
expectedEx.expect(InputValidationException.class);
expectedEx.expectMessage("Invalid name");
KbCredentialsDataAttributes attributes = new KbCredentialsDataAttributes().withName("").withApiKey("key").withCustomerId("custId").withUrl("http://example.com");
validator.validateAttributes(attributes);
}
Aggregations