Skip to content

Commit

Permalink
Merge pull request #66 from adamcin/adamcin/change-grand-tour-it-to-u…
Browse files Browse the repository at this point in the history
…nit-tests-for-coveralls

change grand tour it to unit tests for coveralls
  • Loading branch information
adamcin committed Aug 28, 2020
2 parents 21263de + ba4bb1b commit 248311f
Showing 1 changed file with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package net.adamcin.oakpal.it;
package net.adamcin.oakpal.core;

import net.adamcin.oakpal.api.ProgressCheck;
import net.adamcin.oakpal.api.Violation;
Expand All @@ -31,14 +31,16 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static net.adamcin.oakpal.api.JavaxJson.obj;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class GrandTourIT {
public class OakMachineCaliperTest {

private File grandTourPackage = TestPackageUtil.getCaliperPackage();

Expand All @@ -49,7 +51,7 @@ public class GrandTourIT {
"oakpal-caliper.ui.apps.publish",
"oakpal-caliper.ui.content",
"oakpal-caliper.ui.content.subc1",
"oakpal-caliper.ui.content.suba2",
// not actually installed: "oakpal-caliper.ui.content.suba2",
"oakpal-caliper.ui.content.subb3"
);

Expand Down Expand Up @@ -106,4 +108,40 @@ public Collection<Violation> getReportedViolations() {
assertEquals("expect identified packages in order", installOrderNoRunModesNoSubs,
identifiedPackageIds.stream().map(PackageId::getName).collect(Collectors.toList()));
}

@Test
public void testScanAllRunModesWithSubs_captureIdentifiedPackages() throws Exception {
final List<PackageId> identifiedPackageIds = new ArrayList<>();
final ProgressCheck check = new ProgressCheck() {
@Override
public void identifyPackage(final PackageId packageId, final File file) {
identifiedPackageIds.add(packageId);
}

@Override
public void identifySubpackage(final PackageId packageId, final PackageId parentId) {
identifiedPackageIds.add(packageId);
}

@Override
public void identifyEmbeddedPackage(final PackageId packageId, final PackageId parentId, final String jcrPath) {
identifiedPackageIds.add(packageId);
}

@Override
public Collection<Violation> getReportedViolations() {
return Collections.emptyList();
}
};
OakpalPlan.fromJson(obj().get())
.toOakMachineBuilder(null, getClass().getClassLoader())
.withProgressCheck(check, new SlingJcrInstaller().newInstance(obj().get()))
.withSlingSimulator(DefaultSlingSimulator.instance())
.withRunModes(Stream.of("author", "publish").collect(Collectors.toSet()))
.build()
.scanPackage(grandTourPackage);

assertEquals("expect identified packages in set", new HashSet<>(installOrderFull),
identifiedPackageIds.stream().map(PackageId::getName).collect(Collectors.toSet()));
}
}

0 comments on commit 248311f

Please sign in to comment.