Skip to content

Commit

Permalink
[#1340] floating license pack issuing does not work for template
Browse files Browse the repository at this point in the history
fix 'equals' error on finding Feature Grant prototype
  • Loading branch information
eparovyshnaya committed Apr 5, 2024
1 parent 379fa28 commit 4ed15b4
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,32 +188,32 @@ private Collection<FeatureGrant> featureGrants(FloatingLicensePack pack) {
private FeatureGrant featureGrant(LicensePlanFeatureDescriptor feature, FloatingLicensePack pack, int no) {
FeatureGrant grant = new EmptyFeatureGrant().get();
String fid = feature.getFeature().getIdentifier();
grant.getFeature().setIdentifier(fid);
grant.setCapacity(request.defaultCapacity());
grant.setIdentifier(String.format("%s#%d", request.identifier(), no)); //$NON-NLS-1$
grant.setPack(pack);
grant.setCapacity(request.defaultCapacity());
grant.getFeature().setIdentifier(fid);
grant.getFeature().setVersionMatch(version(feature));

Check warning on line 194 in bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/FloatingLicensePackFromRequest.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/FloatingLicensePackFromRequest.java#L192-L194

Added lines #L192 - L194 were not covered by tests
grant.setValid(featureGrantPeriod(fid));
grant.setVivid(featureGrantVivid(fid));
grant.getFeature().setVersionMatch(version(feature));
grant.setPack(pack);

Check warning on line 197 in bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/FloatingLicensePackFromRequest.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/FloatingLicensePackFromRequest.java#L197

Added line #L197 was not covered by tests
return grant;
}

private ValidityPeriod featureGrantPeriod(String feature) {
return template//
.flatMap(l -> forFeature(l.getFeatures(), feature)) //
.flatMap(pack -> forFeature(pack.getFeatures(), feature)) //

Check warning on line 203 in bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/FloatingLicensePackFromRequest.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/FloatingLicensePackFromRequest.java#L203

Added line #L203 was not covered by tests
.map(g -> EcoreUtil.copy(g.getValid()))//
.orElseGet(this::period);
}

private long featureGrantVivid(String feature) {
return template//
.flatMap(l -> forFeature(l.getFeatures(), feature)) //
.flatMap(pack -> forFeature(pack.getFeatures(), feature)) //

Check warning on line 210 in bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/FloatingLicensePackFromRequest.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/FloatingLicensePackFromRequest.java#L210

Added line #L210 was not covered by tests
.map(FeatureGrant::getVivid)//
.orElse(60L);
}

private Optional<FeatureGrant> forFeature(List<FeatureGrant> all, String feature) {
return all.stream().filter(g -> feature.equals(g.getFeature())).findFirst();
return all.stream().filter(g -> feature.equals(g.getFeature().getIdentifier())).findFirst();

Check warning on line 216 in bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/FloatingLicensePackFromRequest.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/FloatingLicensePackFromRequest.java#L216

Added line #L216 was not covered by tests
}

private VersionMatch version(LicensePlanFeatureDescriptor feature) {
Expand Down

0 comments on commit 4ed15b4

Please sign in to comment.