use of com.developmentontheedge.be5.env.Injector in project be5 by DevelopmentOnTheEdge.
the class Menu method getDefaultAction.
private Action getDefaultAction(Injector injector, EntityType entityType) {
UserAwareMeta userAwareMeta = injector.get(UserAwareMeta.class);
List<String> roles = UserInfoHolder.getCurrentRoles();
String language = UserInfoHolder.getLanguage();
List<RootNode> entities = collectEntities(injector.getMeta(), userAwareMeta, language, roles, false, entityType);
for (RootNode rootNode : entities) {
if (rootNode.action != null) {
if (rootNode.isDefault)
return rootNode.action;
} else if (rootNode.children != null) {
for (QueryNode node : rootNode.children) {
if (node.isDefault)
return node.action;
}
}
}
for (RootNode rootNode : entities) {
if (rootNode.action != null) {
return rootNode.action;
} else if (rootNode.children != null) {
for (QueryNode node : rootNode.children) {
return node.action;
}
}
}
return null;
}
use of com.developmentontheedge.be5.env.Injector in project be5 by DevelopmentOnTheEdge.
the class UserInfoComponentTest method generate.
@Test
public void generate() throws Exception {
Response response = mock(Response.class);
component.generate(getMockRequest(""), response, injector);
verify(response).sendAsRawJson(new UserInfoComponent.State(true, TEST_USER, Collections.singletonList(RoleType.ROLE_ADMINISTRATOR), Collections.singletonList(RoleType.ROLE_ADMINISTRATOR), any(Date.class)));
}
use of com.developmentontheedge.be5.env.Injector in project be5 by DevelopmentOnTheEdge.
the class UserInfoComponentTest method testGuest.
@Test
public void testGuest() throws Exception {
userHelper.initGuest(null);
Response response = mock(Response.class);
component.generate(getMockRequest(""), response, injector);
verify(response).sendAsRawJson(new UserInfoComponent.State(false, RoleType.ROLE_GUEST, Collections.singletonList(RoleType.ROLE_GUEST), Collections.singletonList(RoleType.ROLE_GUEST), any(Date.class)));
}
use of com.developmentontheedge.be5.env.Injector in project be5 by DevelopmentOnTheEdge.
the class UserInfoComponentTest method generateSelectRolesAndSendNewState.
@Test
public void generateSelectRolesAndSendNewState() throws Exception {
Response response = mock(Response.class);
component.generate(getSpyMockRequest("selectRoles", ImmutableMap.of("roles", RoleType.ROLE_ADMINISTRATOR)), response, injector);
verify(response).sendAsRawJson(eq(ImmutableList.of(RoleType.ROLE_ADMINISTRATOR)));
verify(SqlServiceMock.mock).update("UPDATE user_prefs SET pref_value = ? WHERE pref_name = ? AND user_name = ?", "('Administrator')", "current-role-list", "testUser");
verify(SqlServiceMock.mock).insert("INSERT INTO user_prefs VALUES( ?, ?, ? )", "testUser", "current-role-list", "('Administrator')");
initUserWithRoles(RoleType.ROLE_GUEST);
}
use of com.developmentontheedge.be5.env.Injector in project be5 by DevelopmentOnTheEdge.
the class QueryBuilder method update.
private void update(String sql, Injector injector) {
Object id = injector.getSqlService().update(sql);
resourceDataList.add(new ResourceData("result", FrontendConstants.STATIC_ACTION, new StaticPagePresentation("Update was successful", id + " row(s) affected"), null));
}
Aggregations