SuperX-Kernmodul
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
2.2 KiB

package de.superx.common;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.junit.Test;
import de.memtext.tree.KeyParentEqualException;
import de.memtext.tree.NoMainEntryException;
import de.superx.BaseDbTest;
import freemarker.template.TemplateException;
public class MaskeTest extends BaseDbTest {
@Test
public void testStandardLayout()
throws TemplateException, KeyParentEqualException, CloneNotSupportedException,
SichtException, NoMainEntryException, IOException, SQLException, DBServletException {
Maske maske = new Maske("test", user, Integer.valueOf(26020), Locale.GERMANY);
List<Stylesheet> stylesheets = maske.getTableStyleSheets();
int countGenerischesStandardlayout = (int) stylesheets
.stream()
.filter(stylesheet -> stylesheet.getCaption().toLowerCase().startsWith("generisches standardlayout"))
.count();
assertEquals("Only one style \"Generisches Standardlayout\"", Integer.valueOf(1), Integer.valueOf(countGenerischesStandardlayout));
}
@Test
public void testRoleInfo()
throws TemplateException, KeyParentEqualException, CloneNotSupportedException,
SichtException, NoMainEntryException, IOException, SQLException, DBServletException {
Map<String,Map<String,String>> rightsMap = new HashMap<>();
final String ROLE = "ROLE_BI_ADMIN";
final Integer ROLE_ID = Integer.valueOf(42);
rightsMap.put(ROLE, null);
user.setRoleId(ROLE_ID);
user.setRights(rightsMap, ROLE);
Maske maske = new Maske("test", user, Integer.valueOf(26020), Locale.GERMANY);
String processingResult = maske.fmProcess(user, "${UserRole}");
assertEquals("Freemarker substitution UserRole", processingResult, ROLE);
processingResult = maske.fmProcess(user, "${UserRoleId}");
assertEquals("Freemarker substitution UserRoleId", processingResult, ROLE_ID.toString());
}
}