Skip to content

Commit

Permalink
Updated Unit-Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cuioss committed Jul 10, 2023
1 parent 33bdd5d commit 49471c4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,11 @@ void shouldDelegateToConfigurableNavigationHandler() {
assertFalse(mockNavigationHandler.isAddNavigationCalled());
assertTrue(mockNavigationHandler.isGetNavigationCaseCalled());
}

@Test
void shouldGracefullyHandleNullAsHandler() {
var underTest = new BaseDelegatingNavigationHandler(null);
assertNull(underTest.getNavigationCase(getFacesContext(), SOME, SOME));
assertTrue(underTest.getNavigationCases().isEmpty());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package de.cuioss.jsf.api.converter;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

import de.cuioss.jsf.api.security.CuiSanitizer;
import de.cuioss.test.jsf.converter.AbstractConverterTest;
import de.cuioss.test.jsf.converter.TestItems;

Expand All @@ -11,7 +16,26 @@ class HtmlSanitizingConverterTest extends AbstractConverterTest<HtmlSanitizingCo
@Override
public void populate(final TestItems<String> testItems) {
testItems.addRoundtripValues(PLAIN_TEXT).addValidObjectWithStringResult(SIMPLE_HTML, PLAIN_TEXT);
}

@Test
void shouldBeConfigurable() {
var converter = getConverter();
converter.setStrategy(CuiSanitizer.PASSTHROUGH.name());
assertEquals(SIMPLE_HTML, converter.getAsString(getFacesContext(), getComponent(), SIMPLE_HTML));
}

@Test
void shouldIgnoreEmptyConfig() {
var converter = getConverter();
converter.setStrategy("");
assertEquals(PLAIN_TEXT, converter.getAsString(getFacesContext(), getComponent(), SIMPLE_HTML));
}

@Test
void shouldHandleFullSanitation() {
var converter = getConverter();
assertEquals("", converter.getAsString(getFacesContext(), getComponent(), "<p></p>"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
*/
@ResourceDependency(library = "javascript.enabler", name = "enabler.help_text.js", target = "head")
@FacesComponent(BootstrapFamily.HELP_TEXT_COMPONENT)
@SuppressWarnings("java:S110") // owolff: artifact of jsf structure
public class HelpTextComponent extends BaseCuiHtmlHiddenInputComponent implements ContainerPlugin {

private static final CuiLogger log = new CuiLogger(HelpTextComponent.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import de.cuioss.test.jsf.config.component.VerifyComponentProperties;
import de.cuioss.test.jsf.config.decorator.ComponentConfigDecorator;

@VerifyComponentProperties(of = { "titleKey", "titleValue", "contentKey", "contentValue", "contentEscape" })
@VerifyComponentProperties(
of = { "titleKey", "titleValue", "contentKey", "contentValue", "contentEscape", "buttonAlign", "renderButton" })
@JsfTestConfiguration(CoreJsfTestConfiguration.class)
class HelpTextComponentTest extends AbstractComponentTest<HelpTextComponent> implements ComponentConfigurator {

Expand Down

0 comments on commit 49471c4

Please sign in to comment.