refactored test data generation. Refactored entity factor methods.

Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-05-31 08:51:49 +02:00
parent a4e0fc2457
commit 7a98c58407
137 changed files with 2937 additions and 2593 deletions

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.artifacts.smtable;
import java.io.Serializable;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
@@ -66,6 +67,9 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
@Autowired
private transient SoftwareManagement softwareManagement;
@Autowired
private transient EntityFactory entityFactory;
private Label madatoryLabel;
private TextField nameTextField;
@@ -277,8 +281,8 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
uiNotifcation.displayValidationError(
i18n.get("message.duplicate.softwaremodule", new Object[] { name, version }));
} else {
final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(softwareManagement,
name, version, vendor, softwareManagement.findSoftwareModuleTypeByName(type), description);
final SoftwareModule newBaseSoftwareModule = HawkbitCommonUtil.addNewBaseSoftware(entityFactory, name,
version, vendor, softwareManagement.findSoftwareModuleTypeByName(type), description);
if (newBaseSoftwareModule != null) {
/* display success message */
uiNotifcation.displaySuccess(i18n.get("message.save.success", new Object[] {

View File

@@ -13,6 +13,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -93,6 +94,9 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
@Autowired
private transient SoftwareManagement swTypeManagementService;
@Autowired
private transient EntityFactory entityFactory;
@Autowired
private transient EventBus.SessionEventBus eventBus;
@@ -625,8 +629,8 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
}
if (null != typeNameValue && null != typeKeyValue) {
SoftwareModuleType newSWType = swTypeManagementService.generateSoftwareModuleType(typeKeyValue,
typeNameValue, typeDescValue, assignNumber);
SoftwareModuleType newSWType = entityFactory.generateSoftwareModuleType(typeKeyValue, typeNameValue,
typeDescValue, assignNumber);
newSWType.setColour(colorPicked);
if (null != typeDescValue) {

View File

@@ -13,6 +13,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -41,6 +42,7 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery<Distribution
private final Sort sort = new Sort(Direction.ASC, "name");
private transient Page<DistributionSetType> firstPageDistSetType = null;
private transient DistributionSetManagement distributionSetManagement;
private transient EntityFactory entityFactory;
/**
* Parametric constructor.
@@ -57,7 +59,7 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery<Distribution
@Override
protected DistributionSetType constructBean() {
final DistributionSetType result = distributionSetManagement.generateDistributionSetType("", "", "");
final DistributionSetType result = getEntityFactory().generateDistributionSetType("", "", "");
result.setColour("");
return result;
}
@@ -81,6 +83,13 @@ public class DistributionSetTypeBeanQuery extends AbstractBeanQuery<Distribution
return distributionSetManagement;
}
private EntityFactory getEntityFactory() {
if (entityFactory == null) {
entityFactory = SpringContextHelper.getBean(EntityFactory.class);
}
return entityFactory;
}
@Override
protected List<DistributionSetType> loadBeans(final int startIndex, final int count) {
Page<DistributionSetType> typeBeans;

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.common;
import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -31,6 +32,7 @@ public class SoftwareModuleTypeBeanQuery extends AbstractBeanQuery<SoftwareModul
private final Sort sort = new Sort(Direction.ASC, "name");
private transient Page<SoftwareModuleType> firstPageSwModuleType = null;
private transient SoftwareManagement softwareManagement;
private transient EntityFactory entityFactory;
/**
* Parametric constructor.
@@ -47,7 +49,14 @@ public class SoftwareModuleTypeBeanQuery extends AbstractBeanQuery<SoftwareModul
@Override
protected SoftwareModuleType constructBean() {
return softwareManagement.generateSoftwareModuleType();
return getEntityFactory().generateSoftwareModuleType();
}
private EntityFactory getEntityFactory() {
if (entityFactory == null) {
entityFactory = SpringContextHelper.getBean(EntityFactory.class);
}
return entityFactory;
}
@Override

View File

@@ -14,9 +14,9 @@ import java.util.List;
import java.util.Set;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.jpa.DistributionSetRepository;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.common.CoordinatesToColor;
@@ -114,7 +114,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
private transient DistributionSetManagement distributionSetManagement;
@Autowired
private transient DistributionSetRepository distributionSetRepository;
private transient EntityFactory entityFactory;
/**
* Instance of ColorPickerPreview.
@@ -654,8 +654,8 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeDesc.getValue());
final List<Long> itemIds = (List<Long>) selectedTable.getItemIds();
if (null != typeNameValue && null != typeKeyValue && null != itemIds && !itemIds.isEmpty()) {
DistributionSetType newDistType = distributionSetManagement.generateDistributionSetType(typeKeyValue,
typeNameValue, typeDescValue);
DistributionSetType newDistType = entityFactory.generateDistributionSetType(typeKeyValue, typeNameValue,
typeDescValue);
for (final Long id : itemIds) {
final Item item = selectedTable.getItem(id);
final String distTypeName = (String) item.getItemProperty(DIST_TYPE_NAME).getValue();

View File

@@ -13,6 +13,7 @@ import java.util.concurrent.Executor;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
@@ -95,6 +96,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
@Qualifier("uiExecutor")
private transient Executor executor;
@Autowired
private transient EntityFactory entityFactory;
private HorizontalLayout breadcrumbLayout;
private Button breadcrumbButton;
@@ -503,7 +507,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
}
private void createTargetFilterQuery() {
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.generateTargetFilterQuery();
final TargetFilterQuery targetFilterQuery = entityFactory.generateTargetFilterQuery();
targetFilterQuery.setName(nameTextField.getValue());
targetFilterQuery.setQuery(queryTextField.getValue());
targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery);

View File

@@ -16,6 +16,7 @@ import java.util.Map;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.jpa.TenantMetaDataRepository;
@@ -94,6 +95,9 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
@Autowired
private transient TenantMetaDataRepository tenantMetaDataRepository;
@Autowired
private transient EntityFactory entityFactory;
private Button saveDistributionBtn;
private Button discardDistributionBtn;
private TextField distNameTextField;
@@ -145,12 +149,12 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
setSizeUndefined();
addComponents(madatoryLabel, distsetTypeNameComboBox, distNameTextField, distVersionTextField, descTextArea,
reqMigStepCheckbox);
addComponent(buttonsLayout);
setComponentAlignment(madatoryLabel, Alignment.MIDDLE_LEFT);
distNameTextField.focus();
}
}
/**
* Create required UI components.
@@ -297,7 +301,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
if (mandatoryCheck(name, version, distSetTypeName) && duplicateCheck(name, version)) {
final String desc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
final boolean isMigStepReq = reqMigStepCheckbox.getValue();
DistributionSet newDist = distributionSetManagement.generateDistributionSet();
DistributionSet newDist = entityFactory.generateDistributionSet();
setDistributionValues(newDist, name, version, distSetTypeName, desc, isMigStepReq);
newDist = distributionSetManagement.createDistributionSet(newDist);

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.management.dstag;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
@@ -48,6 +49,9 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo
@Autowired
private transient UINotification uiNotification;
@Autowired
private transient EntityFactory entityFactory;
private static final String MISSING_TAG_NAME = "message.error.missing.tagname";
private static final String TARGET_TAG_NAME_DYNAMIC_STYLE = "new-target-tag-name";
private static final String MSG_TEXTFIELD_NAME = "textfield.name";
@@ -98,7 +102,7 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo
final String tagDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
if (null != tagNameValue) {
DistributionSetTag newDistTag = tagManagement.generateDistributionSetTag(tagNameValue, tagDescValue,
DistributionSetTag newDistTag = entityFactory.generateDistributionSetTag(tagNameValue, tagDescValue,
new Color(0, 146, 58).getCSS());
if (colorPicked != null) {

View File

@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.ui.management.dstag;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagUpdateEvent;
@@ -53,15 +53,15 @@ public class DistributionTagButtons extends AbstractFilterButtons {
private DistributionTagDropEvent spDistTagDropEvent;
@Autowired
private TagManagement tagManagement;
private ManagementUIState managementUIState;
@Autowired
private ManagementUIState managementUIState;
private transient EntityFactory entityFactory;
@Override
public void init(final AbstractFilterButtonClickBehaviour filterButtonClickBehaviour) {
super.init(filterButtonClickBehaviour);
addNewTag(tagManagement.generateDistributionSetTag("NO TAG"));
addNewTag(entityFactory.generateDistributionSetTag("NO TAG"));
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -143,7 +143,7 @@ public class DistributionTagButtons extends AbstractFilterButtons {
private void refreshTagTable() {
((LazyQueryContainer) getContainerDataSource()).refresh();
removeGeneratedColumn(FILTER_BUTTON_COLUMN);
addNewTag(tagManagement.generateDistributionSetTag("NO TAG"));
addNewTag(entityFactory.generateDistributionSetTag("NO TAG"));
addColumn();
}

View File

@@ -26,6 +26,7 @@ import java.util.concurrent.Executor;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
@@ -97,6 +98,8 @@ public class BulkUploadHandler extends CustomComponent
final TargetBulkUpdateWindowLayout targetBulkUpdateWindowLayout;
private final EntityFactory entityFactory;
/**
*
* @param targetBulkUpdateWindowLayout
@@ -124,6 +127,7 @@ public class BulkUploadHandler extends CustomComponent
this.eventBus = targetBulkUpdateWindowLayout.getEventBus();
distributionSetManagement = SpringContextHelper.getBean(DistributionSetManagement.class);
tagManagement = SpringContextHelper.getBean(TagManagement.class);
entityFactory = SpringContextHelper.getBean(EntityFactory.class);
}
/**
@@ -380,7 +384,7 @@ public class BulkUploadHandler extends CustomComponent
final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
/* create new target entity */
final Target newTarget = targetManagement.generateTarget(newControllerId);
final Target newTarget = entityFactory.generateTarget(newControllerId);
setTargetValues(newTarget, newName, newDesc);
targetManagement.createTarget(newTarget);
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().add(newControllerId);

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.management.targettable;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetIdName;
@@ -69,6 +70,9 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
@Autowired
private transient UINotification uINotification;
@Autowired
private transient EntityFactory entityFactory;
private TextField controllerIDTextField;
private TextField nameTextField;
@@ -245,7 +249,7 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
/* create new target entity */
Target newTarget = targetManagement.generateTarget(newControlllerId);
Target newTarget = entityFactory.generateTarget(newControlllerId);
/* set values to the new target entity */
setTargetValues(newTarget, newName, newDesc);
/* save new target */

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.management.targettag;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagUpdateEvent;
@@ -49,6 +50,9 @@ public class CreateUpdateTargetTagLayout extends CreateUpdateTagLayout {
@Autowired
private transient UINotification uiNotification;
@Autowired
private transient EntityFactory entityFactory;
private Window targetTagWindow;
@Override
@@ -193,7 +197,7 @@ public class CreateUpdateTargetTagLayout extends CreateUpdateTagLayout {
final String tagNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
final String tagDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
if (null != tagNameValue) {
TargetTag newTargetTag = tagManagement.generateTargetTag(tagNameValue);
TargetTag newTargetTag = entityFactory.generateTargetTag(tagNameValue);
if (null != tagDescValue) {
newTargetTag.setDescription(tagDescValue);
}

View File

@@ -12,8 +12,8 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagCreatedBulkEvent;
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagDeletedEvent;
@@ -77,7 +77,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
private SpPermissionChecker permChecker;
@Autowired
private TagManagement tagManagement;
private transient EntityFactory entityFactory;
@Autowired
private transient TargetManagement targetManagement;
@@ -94,7 +94,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
public void init(final TargetTagFilterButtonClick filterButtonClickBehaviour) {
this.filterButtonClickBehaviour = filterButtonClickBehaviour;
super.init(filterButtonClickBehaviour);
addNewTargetTag(tagManagement.generateTargetTag("NO TAG"));
addNewTargetTag(entityFactory.generateTargetTag("NO TAG"));
}
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -294,7 +294,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
private void refreshContainer() {
removeGeneratedColumn(FILTER_BUTTON_COLUMN);
((LazyQueryContainer) getContainerDataSource()).refresh();
addNewTargetTag(tagManagement.generateTargetTag("NO TAG"));
addNewTargetTag(entityFactory.generateTargetTag("NO TAG"));
addColumn();
}

View File

@@ -13,6 +13,7 @@ import java.util.Date;
import java.util.List;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
@@ -108,6 +109,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
@Autowired
private transient UiProperties uiProperties;
@Autowired
private transient EntityFactory entityFactory;
@Autowired
private I18N i18n;
@@ -479,7 +483,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
}
private Rollout saveRollout() {
Rollout rolloutToCreate = rolloutManagement.generateRollout();
Rollout rolloutToCreate = entityFactory.generateRollout();
final int amountGroup = Integer.parseInt(noOfGroups.getValue());
final String targetFilter = getTargetFilterQuery();
final int errorThresoldPercent = getErrorThresoldPercentage(amountGroup);

View File

@@ -19,6 +19,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.TimeZone;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.AssignmentResult;
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -430,7 +431,7 @@ public final class HawkbitCommonUtil {
return trimAndNullIfEmpty(orgText) == null ? SPUIDefinitions.SPACE : orgText;
}
/**
/**
* Find extra height required to increase by all the components to utilize
* the full height of browser for the responsive UI.
*
@@ -760,10 +761,10 @@ public final class HawkbitCommonUtil {
* base software module description
* @return BaseSoftwareModule new base software module
*/
public static SoftwareModule addNewBaseSoftware(final SoftwareManagement softwareManagement, final String bsname,
public static SoftwareModule addNewBaseSoftware(final EntityFactory entityFactory, final String bsname,
final String bsversion, final String bsvendor, final SoftwareModuleType bstype, final String description) {
final SoftwareManagement swMgmtService = SpringContextHelper.getBean(SoftwareManagement.class);
SoftwareModule newSWModule = softwareManagement.generateSoftwareModule();
SoftwareModule newSWModule = entityFactory.generateSoftwareModule();
newSWModule.setType(bstype);
newSWModule.setName(bsname);
newSWModule.setVersion(bsversion);