InlineNotification implements IsElement { public void setType(final InlineNotificationType type) { Stream.of(InlineNotificationType.values()).forEach(availableType -> { removeCSSClass(alert, availableType.getCssClass()); removeCSSClass(icon, availableType.getIcon()); }); addCSSClass(alert, type.getCssClass()); addCSSClass(icon, type.getIcon()); }  @Override HTMLElement getElement(); void setMessage(final String message); void setMessage(final List<String> messages); void setDismissable(); void setType(final InlineNotificationType type);  }
@Test public void testType() { final DOMTokenList alertDomTokenList = mock(DOMTokenList.class); when(alert.getClassList()).thenReturn(alertDomTokenList); final DOMTokenList iconDomTokenList = mock(DOMTokenList.class); when(icon.getClassList()).thenReturn(iconDomTokenList); notification.setType(InlineNotification.InlineNotificationType.SUCCESS); verify(alertDomTokenList).add(InlineNotification.InlineNotificationType.SUCCESS.getCssClass()); verify(iconDomTokenList).add(InlineNotification.InlineNotificationType.SUCCESS.getIcon()); }
@Test public void testPreviousTypeIsCleared() { final DOMTokenList alertDomTokenList = mock(DOMTokenList.class); when(alert.getClassList()).thenReturn(alertDomTokenList); final DOMTokenList iconDomTokenList = mock(DOMTokenList.class); when(icon.getClassList()).thenReturn(iconDomTokenList); when(alertDomTokenList.contains(anyString())).thenReturn(true); when(iconDomTokenList.contains(anyString())).thenReturn(true); notification.setType(InlineNotification.InlineNotificationType.SUCCESS); Stream.of(InlineNotification.InlineNotificationType.values()).forEach(availableType -> { verify(alertDomTokenList).remove(availableType.getCssClass()); verify(iconDomTokenList).remove(availableType.getIcon()); }); }