### Question:
DurationConfig implements ConditionConfig { @Override public Condition generate(Map<String, Object> values) { Preconditions.checkState(matcher != null, "must specify matcher"); Preconditions.checkState(selector != null, "must specify selector"); Preconditions.checkState(duration != null, "must specify a duration"); int duration = FunctionFactory.toInteger(this.duration.toTemplate(), values); Predicate<Model> matcher = FunctionFactory.toModelPredicate(this.matcher.toTemplate(), values); Predicate<Model> selector = FunctionFactory.toModelPredicate(this.selector.toTemplate(), values); return new DurationTrigger(new ModelPredicateMatcher(selector, matcher), this.unit.toMillis(duration)); }  TemplatedExpression getDurationExpression(); void setDurationExpression(TemplatedExpression duration); TimeUnit getUnit(); void setUnit(TimeUnit unit); TemplatedExpression getSelectorExpression(); void setSelectorExpression(TemplatedExpression selector); TemplatedExpression getMatcherExpression(); void setMatcherExpression(TemplatedExpression matcher); @Override String getType(); @Override Condition generate(Map<String, Object> values); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static final String TYPE; }### Answer:
@Test public void testInvalidConfig() { DurationConfig empty = new DurationConfig(); try { empty.generate(ImmutableMap.of()); fail("Allowed to be creqted with missing attributes"); } catch(IllegalStateException e) { } }
@Ignore @Test public void testMissingVariables() { DurationConfig config = createFullConfig(); try { config.generate(ImmutableMap.of()); fail("Allowed to be creqted with missing variables"); } catch(IllegalStateException|IllegalArgumentException e) { } }
@Test public void testItsAllAlright() { DurationConfig config = createFullConfig(); Condition condition = config.generate(ImmutableMap.of( "var1", "dev", "var2", "SERV:note:" )); assertTrue(condition instanceof DurationTrigger); }