Skip to content

Commit

Permalink
okapi interface is a normal interface OKAPI-1199 (#1370)
Browse files Browse the repository at this point in the history
Before this commit, modules could not really require the interface
as it was not considered in dependency resolution (install).

Co-authored-by: julianladisch <[email protected]>
  • Loading branch information
adamdickmeiss and julianladisch authored Jan 28, 2025
1 parent f280d51 commit 4076ffd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
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\","
+ " \"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)));
}
}

0 comments on commit 4076ffd

Please sign in to comment.