/** * Get the {@link TestMixIn} instances associated with this test instance. * @return The {@link TestMixIn} instances associated with this test instance. */ public List<TestMixIn> getMixIns() { List<TestMixIn> mixins = new ArrayList<TestMixIn>(); for (MixInEntry entry : _testMixInInstances.values()) { mixins.add(entry.getMixIn()); } return Collections.unmodifiableList(mixins); }
/** * Returns optional mixin dependencies. * * @param mixIn Mix in asking about dependencies. * @return Dependencies which are not mandatory for mixin */ public Set<TestMixIn> getOptionalDependencies(TestMixIn mixIn) { return Collections.unmodifiableSet(_testMixInInstances.get(mixIn.getClass()).getOptionalDeps()); }
/** * Returns required mixin dependencies. * * @param mixIn Mix in asking about dependencies. * @return Dependencies which are mandatory for mixin */ public Set<TestMixIn> getRequiredDependencies(TestMixIn mixIn) { return Collections.unmodifiableSet(_testMixInInstances.get(mixIn.getClass()).getRequiredDeps()); }
for (Class<? extends TestMixIn> mixin : activeDependencies) { MixInEntry dependency = createMixInRecursively(mixin); requiredDeps.add(dependency.getMixIn()); _testMixInInstances.put(mixin, dependency); if (_testMixInInstances.containsKey(mixin)) { MixInEntry dependency = createMixInRecursively(mixin); optionalDeps.add(dependency.getMixIn()); _testMixInInstances.put(mixin, dependency); MixInEntry entry = new MixInEntry(testMixIn, requiredDeps, optionalDeps);
for (Class<? extends TestMixIn> mixin : activeDependencies) { MixInEntry dependency = createMixInRecursively(mixin); requiredDeps.add(dependency.getMixIn()); _testMixInInstances.put(mixin, dependency); if (_testMixInInstances.containsKey(mixin)) { MixInEntry dependency = createMixInRecursively(mixin); optionalDeps.add(dependency.getMixIn()); _testMixInInstances.put(mixin, dependency); MixInEntry entry = new MixInEntry(testMixIn, requiredDeps, optionalDeps);
/** * Get the "active" {@link TestMixIn} instance of the specified type. * <p/> * This method can only be called from inside a test method. * * @param type The {@link TestMixIn} type, as specified in the {@link SwitchYardTestCaseConfig} annotation. * @param <T> type {@link TestMixIn} type. * @return The {@link TestMixIn} instance. */ public <T extends TestMixIn> T getMixIn(Class<T> type) { if (_testMixInInstances == null || _testMixInInstances.isEmpty()) { Assert.fail("No TestMixIns specified on Test class instance. Use the @TestMixIns annotation."); } if (_testMixInInstances.size() != getMixIns().size()) { Assert.fail("TestMixIn instances only available during test method execution."); } MixInEntry mixIn = _testMixInInstances.get(type); if (mixIn == null) { Assert.fail("Required TestMixIn '" + type.getName() + "' is not specified on TestCase '" + _testInstance.getClass().getName() + "'."); } return type.cast(mixIn.getMixIn()); }
/** * Get the "active" {@link TestMixIn} instance of the specified type. * <p/> * This method can only be called from inside a test method. * * @param type The {@link TestMixIn} type, as specified in the {@link SwitchYardTestCaseConfig} annotation. * @param <T> type {@link TestMixIn} type. * @return The {@link TestMixIn} instance. */ public <T extends TestMixIn> T getMixIn(Class<T> type) { if (_testMixInInstances == null || _testMixInInstances.isEmpty()) { Assert.fail("No TestMixIns specified on Test class instance. Use the @TestMixIns annotation."); } if (_testMixInInstances.size() != getMixIns().size()) { Assert.fail("TestMixIn instances only available during test method execution."); } MixInEntry mixIn = _testMixInInstances.get(type); if (mixIn == null) { Assert.fail("Required TestMixIn '" + type.getName() + "' is not specified on TestCase '" + _testInstance.getClass().getName() + "'."); } return type.cast(mixIn.getMixIn()); }
/** * Returns optional mixin dependencies. * * @param mixIn Mix in asking about dependencies. * @return Dependencies which are not mandatory for mixin */ public Set<TestMixIn> getOptionalDependencies(TestMixIn mixIn) { return Collections.unmodifiableSet(_testMixInInstances.get(mixIn.getClass()).getOptionalDeps()); }
/** * Returns required mixin dependencies. * * @param mixIn Mix in asking about dependencies. * @return Dependencies which are mandatory for mixin */ public Set<TestMixIn> getRequiredDependencies(TestMixIn mixIn) { return Collections.unmodifiableSet(_testMixInInstances.get(mixIn.getClass()).getRequiredDeps()); }
/** * Get the {@link TestMixIn} instances associated with this test instance. * @return The {@link TestMixIn} instances associated with this test instance. */ public List<TestMixIn> getMixIns() { List<TestMixIn> mixins = new ArrayList<TestMixIn>(); for (MixInEntry entry : _testMixInInstances.values()) { mixins.add(entry.getMixIn()); } return Collections.unmodifiableList(mixins); }