Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

okapi interface is a normal interface OKAPI-1199 #1370

Merged
merged 5 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -3010,6 +3010,11 @@ expected that this interface will remain fairly stable over time.
The internal module was introduced in Okapi version 1.9.0, and a fully
detailed ModuleDescriptor in version 1.10.0.

The internal module is always available, but only enabled by default
for `supertenant`.
Other tenants must enable the okapi module to use the Okapi API.
Individual modules should add the `okapi` interface to the `"requires"` or `"optional"` property of their module descriptor.

### Deployment

Deployment is specified by schemas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public static ModuleDescriptor moduleDescriptor(String okapiVersion) {
+ " }, {"
+ " \"id\" : \"okapi\","
+ " \"version\" : \"" + INTERFACE_VERSION + "\","
+ " \"interfaceType\" : \"internal\","
julianladisch marked this conversation as resolved.
Show resolved Hide resolved
+ " \"handlers\" : [ "
// Deployment service
+ " {"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.folio.okapi.bean.TenantModuleDescriptor;
import org.folio.okapi.bean.TenantModuleDescriptor.Action;
import org.folio.okapi.common.OkapiLogger;
import org.folio.okapi.managers.InternalModule;
import org.folio.okapi.testing.UtilityClassTester;
import org.junit.Assert;
import org.junit.Before;
Expand Down Expand Up @@ -1475,4 +1476,33 @@ public void permissionCheckAlreadyMentioned() {
assertThat(errors.get(mda), contains("Undefined permission 'inta.get' in permissionsRequired"));
}

@Test
public void okapiInterface() {
InterfaceDescriptor intOkapi = new InterfaceDescriptor("okapi", "1.0");

ModuleDescriptor mdA = new ModuleDescriptor("modA-1.0.0");
mdA.setRequires(new InterfaceDescriptor[]{intOkapi});

List<TenantModuleDescriptor> tml1 = enableList(mdA);
OkapiError error = Assert.assertThrows(OkapiError.class,
() -> DepResolution.install(map(mdA), map(), tml1, false));
assertThat(error.getMessage(), is("interface okapi required by module modA-1.0.0 not found"));

ModuleDescriptor mdOkapi = InternalModule.moduleDescriptor("1.0");
List<TenantModuleDescriptor> tml2 = enableList(mdA);
DepResolution.install(map(mdA, mdOkapi), map(mdOkapi), tml2, false);
assertThat(tml2, contains(enable(mdA)));

ModuleDescriptor modOkapiB = new ModuleDescriptor("modB-1.0.0");
modOkapiB.setProvides(new InterfaceDescriptor[]{intOkapi});

List<TenantModuleDescriptor> tml3 = enableList(mdA);
error = Assert.assertThrows(OkapiError.class,
() -> DepResolution.install(map(mdA, modOkapiB, mdOkapi), map(), tml3, false));
assertThat(error.getMessage(), is("interface okapi required by module modA-1.0.0 is provided by multiple products: okapi, modB"));

List<TenantModuleDescriptor> tml4 = enableList(mdA, modOkapiB);
DepResolution.install(map(mdA, modOkapiB, mdOkapi), map(), tml4, false);
assertThat(tml4, contains(enable(modOkapiB), enable(mdA)));
}
}
Loading