@BeforeClass
  public static void init() throws Exception {
    applicationContext = mock(ApplicationContext.class);
    dataAccessService = mock(DataAccessService.class);
    translationService = mock(TranslationService.class);

    dataDefinitionService = new DataDefinitionServiceImpl();

    modelXmlToDefinitionConverter = new ModelXmlToDefinitionConverterImpl();
    setField(modelXmlToDefinitionConverter, "dataDefinitionService", dataDefinitionService);
    setField(modelXmlToDefinitionConverter, "dataAccessService", dataAccessService);
    setField(modelXmlToDefinitionConverter, "applicationContext", applicationContext);
    setField(modelXmlToDefinitionConverter, "translationService", translationService);

    given(applicationContext.getBean(CustomHook.class)).willReturn(new CustomHook());

    modelXmlToClassConverter = new ModelXmlToClassConverterImpl();
    ((ModelXmlToClassConverterImpl) modelXmlToClassConverter)
        .setBeanClassLoader(ClassLoader.getSystemClassLoader());

    dataDefinitions =
        performConvert(
            Utils.FULL_FIRST_ENTITY_XML_RESOURCE,
            Utils.FULL_SECOND_ENTITY_XML_RESOURCE,
            Utils.FULL_THIRD_ENTITY_XML_RESOURCE,
            Utils.OTHER_FIRST_ENTITY_XML_RESOURCE,
            Utils.OTHER_SECOND_ENTITY_XML_RESOURCE);

    for (DataDefinition dd : dataDefinitions.toArray(new DataDefinition[dataDefinitions.size()])) {
      if (dd.getName().equals("firstEntity") && dd.getPluginIdentifier().equals("full")) {
        dataDefinition = (InternalDataDefinition) dd;
      }
    }
  }
  @Before
  public final void init() {
    workPlanService = new WorkPlansServiceImpl();

    dataDefinitionService = mock(DataDefinitionService.class);
    TranslationService translationService = mock(TranslationService.class);
    workPlan = mock(Entity.class);
    workPlanDD = mock(DataDefinition.class);

    when(dataDefinitionService.get(
            WorkPlansConstants.PLUGIN_IDENTIFIER, WorkPlansConstants.MODEL_WORK_PLAN))
        .thenReturn(workPlanDD);

    when(translationService.translate(
            Mockito.anyString(), Mockito.any(Locale.class), Mockito.anyString()))
        .thenReturn(TRANSLATED_STRING);

    when(workPlanDD.getName()).thenReturn(WorkPlansConstants.MODEL_WORK_PLAN);
    when(workPlanDD.getPluginIdentifier()).thenReturn(WorkPlansConstants.PLUGIN_IDENTIFIER);
    when(workPlanDD.get(Mockito.anyLong())).thenReturn(workPlan);

    when(workPlan.getDataDefinition()).thenReturn(workPlanDD);
    when(workPlan.getId()).thenReturn(1L);

    ReflectionTestUtils.setField(workPlanService, "dataDefinitionService", dataDefinitionService);
    ReflectionTestUtils.setField(workPlanService, "translationService", translationService);
  }
 private boolean isDynamicDataDefinition(final DataDefinition dataDefinition) {
   return dataDefinition.getPluginIdentifier().equals("qcadooModel")
       && dataDefinition.getName().startsWith("dynamic");
 }
 private boolean hasCorrectProductDataDefinition(final Entity product) {
   DataDefinition dataDef = product.getDataDefinition();
   return BasicConstants.MODEL_PRODUCT.equals(dataDef.getName())
       && BasicConstants.PLUGIN_IDENTIFIER.equals(dataDef.getPluginIdentifier());
 }