use of org.folio.inventory.domain.items.ItemStatusName in project mod-inventory by folio-org.
the class TargetItemStatusValidatorsTest method targetStatusAllowMarkAs.
// @Ignore
@Parameters({ "In process", "In process (non-requestable)", "Intellectual item", "Long missing", "Missing", "Restricted", "Unavailable", "Unknown", "Withdrawn" })
@Test
public void targetStatusAllowMarkAs(String statusName) {
final var targetItemStatusName = forName(statusName);
final var statusValidator = targetItemStatusValidators.getValidator(targetItemStatusName);
assertThat(statusValidator).isNotNull();
List<ItemStatusName> allowedStatuses = new ArrayList<>(statusValidator.getAllStatusesAllowedToMark());
Collections.sort(allowedStatuses);
assertThat(statusValidator.getItemStatusName().value()).isEqualTo(statusName);
System.out.println("Allowed statuses for:" + statusValidator.getItemStatusName());
allowedStatuses.stream().forEach(x -> {
System.out.println("\t\"" + x + "\",");
Item item = new Item(null, null, null, new Status(x), null, null, null);
assertThat(statusValidator.isItemAllowedToMark(item)).isTrue();
});
List<ItemStatusName> disallowedStatuses = new ArrayList<>();
Collections.addAll(disallowedStatuses, ItemStatusName.values());
disallowedStatuses.removeAll(allowedStatuses);
Collections.sort(disallowedStatuses);
System.out.println("Disallowed statuses for:" + statusValidator.getItemStatusName());
disallowedStatuses.stream().forEach(x -> {
System.out.println("\t\"" + x + "\",");
Item item = new Item(null, null, null, new Status(x), null, null, null);
assertThat(statusValidator.isItemAllowedToMark(item)).isFalse();
});
}
use of org.folio.inventory.domain.items.ItemStatusName in project mod-inventory by folio-org.
the class ItemStatusURLTest method canGetItemStatusByFullUrlAndCanGetUrlByStatusName.
@Parameters({ "/mark-in-process,In process", "/mark-in-process-non-requestable,In process (non-requestable)", "/mark-intellectual-item,Intellectual item", "/mark-long-missing,Long missing", "/mark-missing,Missing" })
@Test
public void canGetItemStatusByFullUrlAndCanGetUrlByStatusName(String url, String statusName) {
// Determining the intended target status for a given URL
String dummyUrl = "http://dummy.net/239853$URL$";
final var itemStatus = ItemStatusURL.getItemStatusNameForUrl(dummyUrl.replace("$URL$", url));
assertThat(itemStatus.isPresent()).isTrue();
ItemStatusName itemStatusName = ItemStatusName.forName(statusName);
assertThat(itemStatus.get()).isEqualTo(itemStatusName);
// Determining the URL for a given target status
var itemStatusUrl = ItemStatusURL.getUrlForItemStatusName(itemStatusName);
assertThat(itemStatusUrl.isPresent()).isTrue();
assertThat(itemStatusUrl.get()).isEqualTo(url);
}
Aggregations