private EntityDto getEntityByEntityClassName(String entityName) { EntityDto entity = entityService.getEntityByClassName(entityName); if (entity == null) { throw new EbodacLookupException("Can not find entity named: " + entityName); } return entity; }
private void processAnnotationScanningResults( List<EntityProcessorOutput> entityProcessorOutput, Map<String, List<LookupDto>> lookupProcessingResult) { Map<String, Long> entityIdMappings = new HashMap<>(); for (EntityProcessorOutput result : entityProcessorOutput) { EntityDto processedEntity = result.getEntityProcessingResult(); EntityDto entity = entityService.getEntityByClassName(processedEntity.getClassName()); if (entity == null) { entity = entityService.createEntity(processedEntity); } entityIdMappings.put(entity.getClassName(), entity.getId()); entityService.updateRestOptions(entity.getId(), result.getRestProcessingResult()); entityService.updateTracking(entity.getId(), result.getTrackingProcessingResult()); entityService.addFields(entity, result.getFieldProcessingResult()); entityService.addFilterableFields(entity, result.getUiFilterableProcessingResult()); entityService.addDisplayedFields(entity, result.getUiDisplayableProcessingResult()); entityService.updateSecurityOptions( entity.getId(), processedEntity.getSecurityMode(), processedEntity.getSecurityMembers()); entityService.updateMaxFetchDepth(entity.getId(), processedEntity.getMaxFetchDepth()); entityService.addNonEditableFields(entity, result.getNonEditableProcessingResult()); } for (Map.Entry<String, List<LookupDto>> entry : lookupProcessingResult.entrySet()) { entityService.addLookups(entityIdMappings.get(entry.getKey()), entry.getValue()); } }
private void mockEntity(Class<?> entityClass, long entityId, EntityDto entity) { when(entityService.getEntity(entityId)).thenReturn(entity); when(entityService.getEntityByClassName(entityClass.getName())).thenReturn(entity); when(entity.getClassName()).thenReturn(entityClass.getName()); when(entity.getId()).thenReturn(entityId); }