diff --git a/tests/org.eclipse.passage.lic.json.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.passage.lic.json.tests/META-INF/MANIFEST.MF index c5d6ab73f..02424b8d2 100644 --- a/tests/org.eclipse.passage.lic.json.tests/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.passage.lic.json.tests/META-INF/MANIFEST.MF @@ -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 @@ -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 diff --git a/tests/org.eclipse.passage.lic.json.tests/src/org/eclipse/passage/lic/json/tests/tobemoved/JsonConditionTransportTest.java b/tests/org.eclipse.passage.lic.json.tests/src/org/eclipse/passage/lic/json/tests/tobemoved/JsonConditionTransportTest.java new file mode 100644 index 000000000..26a5ada80 --- /dev/null +++ b/tests/org.eclipse.passage.lic.json.tests/src/org/eclipse/passage/lic/json/tests/tobemoved/JsonConditionTransportTest.java @@ -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 conditions() { + return new TestConditions().conditions(); + } + +} diff --git a/tests/org.eclipse.passage.lic.json.tests/src/org/eclipse/passage/lic/json/tests/tobemoved/TestConditions.java b/tests/org.eclipse.passage.lic.json.tests/src/org/eclipse/passage/lic/json/tests/tobemoved/TestConditions.java new file mode 100644 index 000000000..805533516 --- /dev/null +++ b/tests/org.eclipse.passage.lic.json.tests/src/org/eclipse/passage/lic/json/tests/tobemoved/TestConditions.java @@ -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 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 conditions() { + return conditions; + } + +}