Search in sources :

Example 1 with ViewDefinitionServiceImpl

use of com.qcadoo.view.internal.ViewDefinitionServiceImpl in project qcadoo by qcadoo.

the class ViewDefinitionParserImplTest method init.

@Before
public void init() throws Exception {
    applicationContext = mock(ApplicationContext.class);
    dataDefinitionService = mock(DataDefinitionService.class);
    translationService = mock(TranslationService.class);
    RibbonParserService ribbonService = new RibbonParserService();
    contextualHelpService = mock(ContextualHelpService.class);
    securityRolesService = mock(SecurityRolesService.class);
    viewDefinitionService = new ViewDefinitionServiceImpl();
    hookFactory = new HookFactory();
    setField(hookFactory, "applicationContext", applicationContext);
    viewDefinitionParser = new ViewDefinitionParserImpl();
    setField(viewDefinitionParser, "dataDefinitionService", dataDefinitionService);
    setField(viewDefinitionParser, "viewDefinitionService", viewDefinitionService);
    setField(viewDefinitionParser, "hookFactory", hookFactory);
    setField(viewDefinitionParser, "translationService", translationService);
    setField(viewDefinitionParser, "applicationContext", applicationContext);
    setField(viewDefinitionParser, "contextualHelpService", contextualHelpService);
    setField(viewDefinitionParser, "viewComponentsResolver", viewComponentsResolver);
    setField(viewDefinitionParser, "ribbonService", ribbonService);
    setField(viewDefinitionParser, "securityRolesService", securityRolesService);
    userRoleMock = mock(SecurityRole.class);
    given(securityRolesService.getRoleByIdentifier("ROLE_USER")).willReturn(userRoleMock);
    adminRoleMock = mock(SecurityRole.class);
    given(securityRolesService.getRoleByIdentifier("ROLE_ADMIN")).willReturn(adminRoleMock);
    xml1 = "view/test1.xml";
    xml2 = "view/test2.xml";
    given(applicationContext.getBean(CustomViewService.class)).willReturn(new CustomViewService());
    dataDefinitionA = mock(DataDefinition.class);
    dataDefinitionB = mock(DataDefinition.class);
    FieldDefinition nameA = mock(FieldDefinition.class, "nameA");
    FieldDefinition nameB = mock(FieldDefinition.class, "nameB");
    FieldDefinition hasManyB = mock(FieldDefinition.class, "hasManyB");
    FieldDefinition belongToA = mock(FieldDefinition.class, "belongsToA");
    HasManyType hasManyBType = mock(HasManyType.class);
    BelongsToType belongToAType = mock(BelongsToType.class);
    given(nameA.getDataDefinition()).willReturn(dataDefinitionA);
    given(nameA.getType()).willReturn(new StringType());
    given(nameB.getType()).willReturn(new StringType());
    given(nameB.getDataDefinition()).willReturn(dataDefinitionA);
    given(hasManyB.getType()).willReturn(hasManyBType);
    given(hasManyB.getDataDefinition()).willReturn(dataDefinitionB);
    given(belongToA.getType()).willReturn(belongToAType);
    given(belongToA.getDataDefinition()).willReturn(dataDefinitionB);
    given(hasManyBType.getDataDefinition()).willReturn(dataDefinitionB);
    given(belongToAType.getDataDefinition()).willReturn(dataDefinitionA);
    given(dataDefinitionA.getField("beansB")).willReturn(hasManyB);
    given(dataDefinitionA.getField("name")).willReturn(nameA);
    given(dataDefinitionB.getField("activeA")).willReturn(nameA);
    given(dataDefinitionB.getField("activeB")).willReturn(nameA);
    given(dataDefinitionB.getField("activeC")).willReturn(nameA);
    given(dataDefinitionB.getField("beanA")).willReturn(belongToA);
    given(dataDefinitionB.getField("beanM")).willReturn(belongToA);
    given(dataDefinitionB.getField("beanB")).willReturn(belongToA);
    given(dataDefinitionB.getField("name")).willReturn(nameB);
    given(dataDefinitionA.getName()).willReturn("beanA");
    given(dataDefinitionB.getName()).willReturn("beanB");
    given(dataDefinitionA.getFields()).willReturn(ImmutableMap.of("name", nameA, "beansB", hasManyB));
    given(dataDefinitionB.getFields()).willReturn(ImmutableMap.of("name", nameB, "beanA", belongToA));
    given(dataDefinitionService.get("sample", "beanA")).willReturn(dataDefinitionA);
    given(dataDefinitionService.get("sample", "beanB")).willReturn(dataDefinitionB);
}
Also used : SecurityRole(com.qcadoo.security.api.SecurityRole) CustomViewService(com.qcadoo.view.beans.sample.CustomViewService) StringType(com.qcadoo.model.internal.types.StringType) ViewDefinitionServiceImpl(com.qcadoo.view.internal.ViewDefinitionServiceImpl) FieldDefinition(com.qcadoo.model.api.FieldDefinition) DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) DataDefinition(com.qcadoo.model.api.DataDefinition) RibbonParserService(com.qcadoo.view.internal.ribbon.RibbonParserService) ApplicationContext(org.springframework.context.ApplicationContext) HasManyType(com.qcadoo.model.api.types.HasManyType) BelongsToType(com.qcadoo.model.api.types.BelongsToType) TranslationService(com.qcadoo.localization.api.TranslationService) SecurityRolesService(com.qcadoo.security.api.SecurityRolesService) Before(org.junit.Before)

Aggregations

TranslationService (com.qcadoo.localization.api.TranslationService)1 DataDefinition (com.qcadoo.model.api.DataDefinition)1 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)1 FieldDefinition (com.qcadoo.model.api.FieldDefinition)1 BelongsToType (com.qcadoo.model.api.types.BelongsToType)1 HasManyType (com.qcadoo.model.api.types.HasManyType)1 StringType (com.qcadoo.model.internal.types.StringType)1 SecurityRole (com.qcadoo.security.api.SecurityRole)1 SecurityRolesService (com.qcadoo.security.api.SecurityRolesService)1 CustomViewService (com.qcadoo.view.beans.sample.CustomViewService)1 ViewDefinitionServiceImpl (com.qcadoo.view.internal.ViewDefinitionServiceImpl)1 RibbonParserService (com.qcadoo.view.internal.ribbon.RibbonParserService)1 Before (org.junit.Before)1 ApplicationContext (org.springframework.context.ApplicationContext)1