@Test public void exceptionIsThrownForWronglyConstructedJsonDictionary_6() { final ImmutableMap<String, ? extends Object> template = ImmutableMap.of("status", "PASS", "elapsedtime", 100, "message", "error"); final Set<Set<String>> allKeysCombinations = newHashSet( Sets.powerSet(newHashSet("status", "elapsedtime", "message"))); allKeysCombinations.remove(newHashSet("status", "elapsedtime", "message")); for (final Set<String> combination : allKeysCombinations) { final Map<String, Object> attributes = new HashMap<>(); for (final String key : combination) { attributes.put(key, template.get(key)); } final Map<String, Object> eventMap = ImmutableMap.of("end_suite", newArrayList("suite", attributes)); assertThatIllegalArgumentException().isThrownBy(() -> SuiteEndedEvent.from(eventMap)) .withMessage("Suite ended event should have status, elapsed time and message attributes") .withNoCause(); } }
public static SuiteEndedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("end_suite"); final String name = (String) arguments.get(0); final Map<?, ?> attributes = (Map<?, ?>) arguments.get(1); final Integer elapsedTime = (Integer) attributes.get("elapsedtime"); final String errorMessage = (String) attributes.get("message"); final String suiteStatus = (String) attributes.get("status"); if (elapsedTime == null || errorMessage == null || suiteStatus == null) { throw new IllegalArgumentException( "Suite ended event should have status, elapsed time and message attributes"); } return new SuiteEndedEvent(name, elapsedTime, Status.valueOf(suiteStatus), errorMessage); }
SuiteEndedEvent { public static SuiteEndedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("end_suite"); final String name = (String) arguments.get(0); final Map<?, ?> attributes = (Map<?, ?>) arguments.get(1); final Integer elapsedTime = (Integer) attributes.get("elapsedtime"); final String errorMessage = (String) attributes.get("message"); final String suiteStatus = (String) attributes.get("status"); if (elapsedTime == null || errorMessage == null || suiteStatus == null) { throw new IllegalArgumentException( "Suite ended event should have status, elapsed time and message attributes"); } return new SuiteEndedEvent(name, elapsedTime, Status.valueOf(suiteStatus), errorMessage); } }
SuiteEndedEvent { public static SuiteEndedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("end_suite"); final String name = (String) arguments.get(0); final Map<?, ?> attributes = (Map<?, ?>) arguments.get(1); final Integer elapsedTime = (Integer) attributes.get("elapsedtime"); final String errorMessage = (String) attributes.get("message"); final String suiteStatus = (String) attributes.get("status"); if (elapsedTime == null || errorMessage == null || suiteStatus == null) { throw new IllegalArgumentException( "Suite ended event should have status, elapsed time and message attributes"); } return new SuiteEndedEvent(name, elapsedTime, Status.valueOf(suiteStatus), errorMessage); } SuiteEndedEvent(final String name, final int elapsedTime, final Status suiteStatus,
            final String errorMessage); }
SuiteEndedEvent { public static SuiteEndedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("end_suite"); final String name = (String) arguments.get(0); final Map<?, ?> attributes = (Map<?, ?>) arguments.get(1); final Integer elapsedTime = (Integer) attributes.get("elapsedtime"); final String errorMessage = (String) attributes.get("message"); final String suiteStatus = (String) attributes.get("status"); if (elapsedTime == null || errorMessage == null || suiteStatus == null) { throw new IllegalArgumentException( "Suite ended event should have status, elapsed time and message attributes"); } return new SuiteEndedEvent(name, elapsedTime, Status.valueOf(suiteStatus), errorMessage); } SuiteEndedEvent(final String name, final int elapsedTime, final Status suiteStatus,
            final String errorMessage); static SuiteEndedEvent from(final Map<String, Object> eventMap); String getName(); int getElapsedTime(); Status getStatus(); String getErrorMessage(); @Override boolean equals(final Object obj); @Override int hashCode(); }
SuiteEndedEvent { public static SuiteEndedEvent from(final Map<String, Object> eventMap) { final List<?> arguments = (List<?>) eventMap.get("end_suite"); final String name = (String) arguments.get(0); final Map<?, ?> attributes = (Map<?, ?>) arguments.get(1); final Integer elapsedTime = (Integer) attributes.get("elapsedtime"); final String errorMessage = (String) attributes.get("message"); final String suiteStatus = (String) attributes.get("status"); if (elapsedTime == null || errorMessage == null || suiteStatus == null) { throw new IllegalArgumentException( "Suite ended event should have status, elapsed time and message attributes"); } return new SuiteEndedEvent(name, elapsedTime, Status.valueOf(suiteStatus), errorMessage); } SuiteEndedEvent(final String name, final int elapsedTime, final Status suiteStatus,
            final String errorMessage); static SuiteEndedEvent from(final Map<String, Object> eventMap); String getName(); int getElapsedTime(); Status getStatus(); String getErrorMessage(); @Override boolean equals(final Object obj); @Override int hashCode();  }