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);
}
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);
}
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);
}
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);
}
Aggregations