@Test public void systemNotificationFields() throws Exception { doLogin(); ServerTab serverCfg = main.openServer(); serverCfg.getNotificationsEnabled().check(true); serverCfg.getNotificationEmails().type("[email protected],[email protected]"); serverCfg.getNotificationRoles().add("anonymous"); serverCfg.getNotificationRoles().add("admin"); MockListener<GlobalConfigurationResourceResponse> ml = MockHelper.listen( GlobalConfigurationPlexusResource.RESOURCE_URI, new MockListener<GlobalConfigurationResourceResponse>() { @Override public void onPayload(Object payload, MockEvent evt) { if (!Method.PUT.equals(evt.getMethod())) { evt.block(); } else { assertThat(payload, not(nullValue())); assertThat(payload, is(instanceOf(GlobalConfigurationResourceResponse.class))); GlobalConfigurationResourceResponse resource = (GlobalConfigurationResourceResponse) payload; assertThat(resource.getData().getSystemNotificationSettings(), not(nullValue())); assertThat( resource.getData().getSystemNotificationSettings().getEmailAddresses(), equalTo("[email protected],[email protected]")); assertThat( resource.getData().getSystemNotificationSettings().getRoles().size(), equalTo(2)); assertThat( resource.getData().getSystemNotificationSettings().getRoles().get(0), equalTo("anonymous")); assertThat( resource.getData().getSystemNotificationSettings().getRoles().get(1), equalTo("admin")); assertThat( resource.getData().getSystemNotificationSettings().isEnabled(), equalTo(true)); } } }); serverCfg.save(); Thread.sleep(1000); assertNotNull(ml.waitForPayload(GlobalConfigurationResourceResponse.class)); MockHelper.checkAndClean(); }
public static void checkAssertions() { if (responses.get() != null) { for (MockResponse mockResponse : responses.get()) { mockResponse.checkAssertion(); } } if (listeners.get() != null) { for (MockListener<Object> mockListener : listeners.get()) { mockListener.checkAssertion(); } } }
public static void checkExecutions() { if (responses.get() != null) { for (MockResponse entry : responses.get()) { if (!entry.wasExecuted()) { String uri = mockResponses.inverse().get(entry); throw new AssertionError("Mock for '" + uri + "' was never executed"); } } } if (listeners.get() != null) { for (MockListener<Object> entry : listeners.get()) { if (!entry.wasExecuted()) { String uri = mockListeneres.inverse().get(entry); throw new AssertionError("Listener for '" + uri + "' was never executed"); } } } }