Search in sources :

Example 1 with DataDefinitionService

use of com.qcadoo.model.api.DataDefinitionService 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)

Example 2 with DataDefinitionService

use of com.qcadoo.model.api.DataDefinitionService in project mes by qcadoo.

the class CommonReasonTypeModelHooksTest method init.

@Before
public void init() {
    MockitoAnnotations.initMocks(this);
    commonReasonTypeModelHooks = new CommonReasonTypeModelHooks();
    deviationModelDescriber = new DeviationModelDescriber("reasonPlugin", "reasonModel", "reasonField");
    DataDefinitionService dataDefinitionService = mock(DataDefinitionService.class);
    given(dataDefinitionService.get(deviationModelDescriber.getModelPlugin(), deviationModelDescriber.getModelName())).willReturn(reasonDD);
    ReflectionTestUtils.setField(commonReasonTypeModelHooks, "dataDefinitionService", dataDefinitionService);
}
Also used : DeviationModelDescriber(com.qcadoo.mes.orders.constants.deviationReasonTypes.DeviationModelDescriber) DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) Before(org.junit.Before)

Example 3 with DataDefinitionService

use of com.qcadoo.model.api.DataDefinitionService in project mes by qcadoo.

the class AdvancedGenealogyTreeViewListenersTest method init.

@Before
public void init() {
    viewListeners = new AdvancedGenealogyTreeViewListeners();
    DataDefinitionService dataDefinitionService = mock(DataDefinitionService.class);
    dataDefinition = mock(DataDefinition.class);
    locale = Locale.getDefault();
    when(dataDefinitionService.get(AdvancedGenealogyConstants.PLUGIN_IDENTIFIER, AdvancedGenealogyConstants.MODEL_BATCH)).thenReturn(dataDefinition);
    advancedGenealogyTreeService = mock(AdvancedGenealogyTreeService.class);
    ReflectionTestUtils.setField(viewListeners, "dataDefinitionService", dataDefinitionService);
    ReflectionTestUtils.setField(viewListeners, "advancedGenealogyTreeService", advancedGenealogyTreeService);
    view = mock(ViewDefinitionState.class);
    state = mock(ComponentState.class);
    FormComponent formComponent = mock(FormComponent.class);
    formEntity = mock(Entity.class);
    batchLookup = mock(ComponentState.class);
    when(view.getComponentByReference(QcadooViewConstants.L_FORM)).thenReturn(formComponent);
    when(formComponent.getEntity()).thenReturn(formEntity);
    when(view.getComponentByReference("batchLookup")).thenReturn(batchLookup);
    when(state.getLocale()).thenReturn(locale);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) DataDefinition(com.qcadoo.model.api.DataDefinition) ComponentState(com.qcadoo.view.api.ComponentState) Before(org.junit.Before)

Example 4 with DataDefinitionService

use of com.qcadoo.model.api.DataDefinitionService in project mes by qcadoo.

the class TechnologyDataProviderImplTest method init.

@Before
public void init() {
    MockitoAnnotations.initMocks(this);
    technologyDataProvider = new TechnologyDataProviderImpl();
    DataDefinitionService dataDefinitionService = mock(DataDefinitionService.class);
    given(dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY)).willReturn(technologyDataDef);
    ReflectionTestUtils.setField(technologyDataProvider, "dataDefinitionService", dataDefinitionService);
}
Also used : DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) Before(org.junit.Before)

Aggregations

DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)4 Before (org.junit.Before)4 DataDefinition (com.qcadoo.model.api.DataDefinition)2 TranslationService (com.qcadoo.localization.api.TranslationService)1 DeviationModelDescriber (com.qcadoo.mes.orders.constants.deviationReasonTypes.DeviationModelDescriber)1 Entity (com.qcadoo.model.api.Entity)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 ComponentState (com.qcadoo.view.api.ComponentState)1 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)1 FormComponent (com.qcadoo.view.api.components.FormComponent)1 CustomViewService (com.qcadoo.view.beans.sample.CustomViewService)1 ViewDefinitionServiceImpl (com.qcadoo.view.internal.ViewDefinitionServiceImpl)1 RibbonParserService (com.qcadoo.view.internal.ribbon.RibbonParserService)1 ApplicationContext (org.springframework.context.ApplicationContext)1