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

Bug 564420 move HC condition miner to new interfaces #262

Merged
merged 2 commits into from
Jun 21, 2020
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
8 changes: 5 additions & 3 deletions tests/org.eclipse.passage.lic.json.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Automatic-Module-Name: org.eclipse.passage.lic.json.tests
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.passage.lic.json.tests
Bundle-Version: 0.5.0.qualifier
Bundle-Version: 0.5.100.qualifier
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
Bundle-Copyright: %Bundle-Copyright
Expand All @@ -12,5 +12,7 @@ Require-Bundle: org.junit;bundle-version="4.12.0",
com.fasterxml.jackson.core.jackson-core;bundle-version="2.9.2",
com.fasterxml.jackson.core.jackson-databind;bundle-version="2.9.2",
org.eclipse.passage.lic.base;bundle-version="0.0.0",
org.eclipse.passage.lic.json;bundle-version="0.0.0"
Export-Package: org.eclipse.passage.lic.json.tests
org.eclipse.passage.lic.json;bundle-version="0.0.0",
org.eclipse.passage.lic.api.tests;bundle-version="0.1.0"
Export-Package: org.eclipse.passage.lic.json.tests,
org.eclipse.passage.lic.json.tests.tobemoved
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*******************************************************************************
* Copyright (c) 2020 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
package org.eclipse.passage.lic.json.tests.tobemoved;

import java.util.Collection;

import org.eclipse.passage.lic.api.tests.conditions.mining.ConditionTransportContractTest;
import org.eclipse.passage.lic.internal.api.conditions.Condition;
import org.eclipse.passage.lic.internal.api.conditions.ValidityPeriodClosed;
import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionTransport;
import org.eclipse.passage.lic.internal.json.tobemoved.JsonConditionTransport;

@SuppressWarnings("restriction")
public final class JsonConditionTransportTest extends ConditionTransportContractTest {

@Override
protected String textual(Condition condition) {
return new StringBuffer() //
.append(condition.feature()).append('|') //
.append(condition.versionMatch().version()).append('|') //
.append(condition.versionMatch().rule().identifier()).append('|') //
.append(textual(((ValidityPeriodClosed) condition.validityPeriod()))).append('|') //
.append(condition.evaluationInstructions().type().identifier()).append('|') //
.append(condition.evaluationInstructions().expression()) //
.toString();

}

private String textual(ValidityPeriodClosed period) {
return String.format("%d-%d", period.from().getTime(), period.to().getTime()); //$NON-NLS-1$
}

@Override
protected ConditionTransport transport() {
return new JsonConditionTransport();
}

@Override
protected Collection<Condition> conditions() {
return new TestConditions().conditions();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*******************************************************************************
* Copyright (c) 2020 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
package org.eclipse.passage.lic.json.tests.tobemoved;

import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;

import org.eclipse.passage.lic.internal.api.conditions.Condition;
import org.eclipse.passage.lic.internal.api.conditions.EvaluationType;
import org.eclipse.passage.lic.internal.base.conditions.BaseCondition;
import org.eclipse.passage.lic.internal.base.conditions.BaseEvaluationInstructions;
import org.eclipse.passage.lic.internal.base.conditions.BaseValidityPeriodClosed;
import org.eclipse.passage.lic.internal.base.conditions.BaseVersionMatch;
import org.eclipse.passage.lic.internal.base.conditions.MatchingRuleCompatible;
import org.eclipse.passage.lic.internal.base.conditions.MatchingRuleEquivalent;
import org.eclipse.passage.lic.internal.base.conditions.MatchingRulePerfect;

@SuppressWarnings("restriction")
public final class TestConditions {

private final List<Condition> conditions = Arrays.asList(//
new BaseCondition("who-are-you-guys?", //$NON-NLS-1$
new BaseVersionMatch("1.1.1", new MatchingRuleEquivalent()), //$NON-NLS-1$
new BaseValidityPeriodClosed(new Date(), new Date(System.currentTimeMillis() + 1000)), //
new BaseEvaluationInstructions(new EvaluationType.Of("metal-test"), "cow-says=moo;cat-says=meow")), //$NON-NLS-1$ //$NON-NLS-2$
new BaseCondition("extraterrestrial-verifier", //$NON-NLS-1$
new BaseVersionMatch("17.0.8", new MatchingRuleCompatible()), //$NON-NLS-1$
new BaseValidityPeriodClosed(new Date(), new Date(System.currentTimeMillis() + 2000)), //
new BaseEvaluationInstructions(new EvaluationType.Of("barrier-body-asessment"), //$NON-NLS-1$
"heads=1;heands=2;legs=2")), //$NON-NLS-1$
new BaseCondition("good-witch", //$NON-NLS-1$
new BaseVersionMatch("0.32.17.patch5", new MatchingRulePerfect()), //$NON-NLS-1$
new BaseValidityPeriodClosed(new Date(), new Date(System.currentTimeMillis() + 3000)), //
new BaseEvaluationInstructions(new EvaluationType.Of("physical"), "thermal-conductivity=water")) //$NON-NLS-1$ //$NON-NLS-2$
);

Collection<Condition> conditions() {
return conditions;
}

}