From e731543313b663ae02327882897134aa1822c78f Mon Sep 17 00:00:00 2001 From: Jonathan Philip Knoblauch Date: Thu, 3 Mar 2016 10:52:55 +0100 Subject: [PATCH 1/7] Fix for sonar rule: Fields and methods should not have conflicting names Signed-off-by: Jonathan Philip Knoblauch --- .../CreateUpdateSoftwareTypeLayout.java | 8 +- .../artifacts/state/ArtifactUploadState.java | 16 ++-- .../CreateUpdateDistSetTypeLayout.java | 4 +- .../state/ManageDistUIState.java | 16 ++-- .../DistributionAddUpdateWindowLayout.java | 30 ++++---- .../management/state/ManagementUIState.java | 20 ++--- .../rollout/AddUpdateRolloutWindowLayout.java | 76 ++++++++++--------- ...yTokenAuthenticationConfigurationItem.java | 7 +- 8 files changed, 88 insertions(+), 89 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java index b79b53ae0..dc6d1081e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java @@ -438,17 +438,17 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C if (permChecker.hasUpdateDistributionPermission()) { optionValues.add(updateType.getValue()); } - createOptionGroup(optionValues); + createOptionGroupByValues(optionValues); } private void singleMultiOptionGroup() { final List optionValues = new ArrayList<>(); optionValues.add(singleAssign.getValue()); optionValues.add(multiAssign.getValue()); - assignOptionGroup(optionValues); + assignOptionGroupByValues(optionValues); } - private void createOptionGroup(final List tagOptions) { + private void createOptionGroupByValues(final List tagOptions) { createOptiongroup = new OptionGroup("", tagOptions); createOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL); createOptiongroup.addStyleName("custom-option-group"); @@ -458,7 +458,7 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C } } - private void assignOptionGroup(final List tagOptions) { + private void assignOptionGroupByValues(final List tagOptions) { assignOptiongroup = new OptionGroup("", tagOptions); assignOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL); assignOptiongroup.addStyleName("custom-option-group"); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java index 62a09c83b..a502b341c 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java @@ -50,9 +50,9 @@ public class ArtifactUploadState implements Serializable { private boolean swTypeFilterClosed = Boolean.FALSE; - private boolean isSwModuleTableMaximized = Boolean.FALSE; + private boolean swModuleTableMaximized = Boolean.FALSE; - private boolean isArtifactDetailsMaximized = Boolean.FALSE; + private boolean artifactDetailsMaximized = Boolean.FALSE; private final Set selectedDeleteSWModuleTypes = new HashSet<>(); @@ -152,15 +152,15 @@ public class ArtifactUploadState implements Serializable { * @return the isSwModuleTableMaximized */ public boolean isSwModuleTableMaximized() { - return isSwModuleTableMaximized; + return swModuleTableMaximized; } /** * @param isSwModuleTableMaximized * the isSwModuleTableMaximized to set */ - public void setSwModuleTableMaximized(final boolean isSwModuleTableMaximized) { - this.isSwModuleTableMaximized = isSwModuleTableMaximized; + public void setSwModuleTableMaximized(final boolean swModuleTableMaximized) { + this.swModuleTableMaximized = swModuleTableMaximized; } public Set getSelectedDeleteSWModuleTypes() { @@ -171,15 +171,15 @@ public class ArtifactUploadState implements Serializable { * @return the isArtifactDetailsMaximized */ public boolean isArtifactDetailsMaximized() { - return isArtifactDetailsMaximized; + return artifactDetailsMaximized; } /** * @param isArtifactDetailsMaximized * the isArtifactDetailsMaximized to set */ - public void setArtifactDetailsMaximized(final boolean isArtifactDetailsMaximized) { - this.isArtifactDetailsMaximized = isArtifactDetailsMaximized; + public void setArtifactDetailsMaximized(final boolean artifactDetailsMaximized) { + this.artifactDetailsMaximized = artifactDetailsMaximized; } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java index 4fed0dd4b..8d609f628 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java @@ -555,10 +555,10 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co if (permChecker.hasUpdateDistributionPermission()) { optionValues.add(updateDistType.getValue()); } - createOptionGroup(optionValues); + createOptionGroupByValues(optionValues); } - private void createOptionGroup(final List typeOptions) { + private void createOptionGroupByValues(final List typeOptions) { createOptiongroup = new OptionGroup("", typeOptions); createOptiongroup.setId(SPUIDefinitions.CREATE_OPTION_GROUP_DISTRIBUTION_SET_TYPE_ID); createOptiongroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistUIState.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistUIState.java index 7e06a4171..ce31f649b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistUIState.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistUIState.java @@ -62,9 +62,9 @@ public class ManageDistUIState implements Serializable { private final Map deleteSofwareModulesList = new HashMap<>(); - private boolean isSwModuleTableMaximized = Boolean.FALSE; + private boolean swModuleTableMaximized = Boolean.FALSE; - private boolean isDsTableMaximized = Boolean.FALSE; + private boolean dsTableMaximized = Boolean.FALSE; private final Map assignedSoftwareModuleDetails = new HashMap<>(); @@ -219,7 +219,7 @@ public class ManageDistUIState implements Serializable { * @return boolean */ public boolean isDsTableMaximized() { - return isDsTableMaximized; + return dsTableMaximized; } /*** @@ -227,8 +227,8 @@ public class ManageDistUIState implements Serializable { * * @param isDsModuleTableMaximized */ - public void setDsTableMaximized(final boolean isDsModuleTableMaximized) { - isDsTableMaximized = isDsModuleTableMaximized; + public void setDsTableMaximized(final boolean dsModuleTableMaximized) { + dsTableMaximized = dsModuleTableMaximized; } public Map getAssignedSoftwareModuleDetails() { @@ -239,15 +239,15 @@ public class ManageDistUIState implements Serializable { * @return the isSwModuleTableMaximized */ public boolean isSwModuleTableMaximized() { - return isSwModuleTableMaximized; + return swModuleTableMaximized; } /** * @param isSwModuleTableMaximized * the isSwModuleTableMaximized to set */ - public void setSwModuleTableMaximized(final boolean isSwModuleTableMaximized) { - this.isSwModuleTableMaximized = isSwModuleTableMaximized; + public void setSwModuleTableMaximized(final boolean swModuleTableMaximized) { + this.swModuleTableMaximized = swModuleTableMaximized; } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java index dfdbcd9de..21914778e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java @@ -94,8 +94,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { @Autowired private transient TenantMetaDataRepository tenantMetaDataRepository; - private Button saveDistribution; - private Button discardDistribution; + private Button saveDistributionButton; + private Button discardDistributionButton; private TextField distNameTextField; private TextField distVersionTextField; private Label madatoryLabel; @@ -103,7 +103,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { private CheckBox reqMigStepCheckbox; private ComboBox distsetTypeNameComboBox; private boolean editDistribution = Boolean.FALSE; - private Long editDistId = null; + private Long editDistId; private Window addDistributionWindow; private String originalDistName; private String originalDistVersion; @@ -131,9 +131,9 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { final HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSizeFull(); buttonsLayout.setStyleName("dist-buttons-horz-layout"); - buttonsLayout.addComponents(saveDistribution, discardDistribution); - buttonsLayout.setComponentAlignment(saveDistribution, Alignment.BOTTOM_LEFT); - buttonsLayout.setComponentAlignment(discardDistribution, Alignment.BOTTOM_RIGHT); + buttonsLayout.addComponents(saveDistributionButton, discardDistributionButton); + buttonsLayout.setComponentAlignment(saveDistributionButton, Alignment.BOTTOM_LEFT); + buttonsLayout.setComponentAlignment(discardDistributionButton, Alignment.BOTTOM_RIGHT); buttonsLayout.addStyleName("window-style"); /* @@ -186,14 +186,14 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { reqMigStepCheckbox.setId(SPUIComponetIdProvider.DIST_ADD_MIGRATION_CHECK); /* save or update button */ - saveDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_SAVE, "", "", "", true, + saveDistributionButton = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_SAVE, "", "", "", true, FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class); - saveDistribution.addClickListener(event -> saveDistribution()); + saveDistributionButton.addClickListener(event -> saveDistribution()); /* close button */ - discardDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "", true, - FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); - discardDistribution.addClickListener(event -> discardDistribution()); + discardDistributionButton = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "", + true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); + discardDistributionButton.addClickListener(event -> discardDistribution()); } /** @@ -216,7 +216,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { } private void enableSaveButton() { - saveDistribution.setEnabled(true); + saveDistributionButton.setEnabled(true); } private DistributionSetType getDefaultDistributionSetType() { @@ -226,7 +226,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { } private void disableSaveButton() { - saveDistribution.setEnabled(false); + saveDistributionButton.setEnabled(false); } private void saveDistribution() { @@ -415,7 +415,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { distsetTypeNameComboBox.removeStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR); descTextArea.clear(); reqMigStepCheckbox.clear(); - saveDistribution.setEnabled(true); + saveDistributionButton.setEnabled(true); removeListeners(); changedComponents.clear(); } @@ -497,7 +497,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { public void populateValuesOfDistribution(final Long editDistId) { this.editDistId = editDistId; editDistribution = Boolean.TRUE; - saveDistribution.setEnabled(false); + saveDistributionButton.setEnabled(false); final DistributionSet distSet = distributionSetManagement.findDistributionSetByIdWithDetails(editDistId); if (distSet != null) { distNameTextField.setValue(distSet.getName()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/ManagementUIState.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/ManagementUIState.java index 28fb4635f..3184bf923 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/ManagementUIState.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/ManagementUIState.java @@ -62,20 +62,20 @@ public class ManagementUIState implements Serializable { private boolean distTagFilterClosed = true; - private Long targetsTruncated = null; + private Long targetsTruncated; private final AtomicLong targetsCountAll = new AtomicLong(); - private boolean isDsTableMaximized = Boolean.FALSE; + private boolean dsTableMaximized = Boolean.FALSE; // Contains ID and NAme of last selected target private DistributionSetIdName lastSelectedDsIdName; // Contains list of ID and Names of all the selected Targets private Set selectedDsIdName = Collections.emptySet(); - private boolean isTargetTableMaximized = Boolean.FALSE; + private boolean targetTableMaximized = Boolean.FALSE; - private boolean isActionHistoryMaximized = Boolean.FALSE; + private boolean actionHistoryMaximized = Boolean.FALSE; private boolean noDataAvilableTarget = Boolean.FALSE; @@ -255,11 +255,11 @@ public class ManagementUIState implements Serializable { } public boolean isDsTableMaximized() { - return isDsTableMaximized; + return dsTableMaximized; } public void setDsTableMaximized(final boolean isDsTableMaximized) { - this.isDsTableMaximized = isDsTableMaximized; + this.dsTableMaximized = isDsTableMaximized; } public DistributionSetIdName getLastSelectedDsIdName() { @@ -282,7 +282,7 @@ public class ManagementUIState implements Serializable { * @return the isTargetTableMaximized */ public boolean isTargetTableMaximized() { - return isTargetTableMaximized; + return targetTableMaximized; } /** @@ -290,14 +290,14 @@ public class ManagementUIState implements Serializable { * the isTargetTableMaximized to set */ public void setTargetTableMaximized(final boolean isTargetTableMaximized) { - this.isTargetTableMaximized = isTargetTableMaximized; + this.targetTableMaximized = isTargetTableMaximized; } /** * @return the isActionHistoryMaximized */ public boolean isActionHistoryMaximized() { - return isActionHistoryMaximized; + return actionHistoryMaximized; } /** @@ -305,7 +305,7 @@ public class ManagementUIState implements Serializable { * the isActionHistoryMaximized to set */ public void setActionHistoryMaximized(final boolean isActionHistoryMaximized) { - this.isActionHistoryMaximized = isActionHistoryMaximized; + this.actionHistoryMaximized = isActionHistoryMaximized; } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/AddUpdateRolloutWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/AddUpdateRolloutWindowLayout.java index d0cddfb19..3a1deaf65 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/AddUpdateRolloutWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/AddUpdateRolloutWindowLayout.java @@ -128,7 +128,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { private TextArea description; - private Button saveRollout; + private Button saveRolloutBtn; private Button discardRolllout; @@ -138,7 +138,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { private Window addUpdateRolloutWindow; - private Boolean editRollout; + private Boolean editRolloutBtn; private Rollout rolloutForEdit; @@ -167,7 +167,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { * Reset the field values. */ public void resetComponents() { - editRollout = Boolean.FALSE; + editRolloutBtn = Boolean.FALSE; rolloutName.clear(); targetFilterQuery.clear(); resetFields(); @@ -212,7 +212,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { final HorizontalLayout groupLayout = new HorizontalLayout(); groupLayout.setSizeFull(); groupLayout.addComponents(noOfGroups, groupSizeLabel); - groupLayout.setExpandRatio(noOfGroups, 1.0f); + groupLayout.setExpandRatio(noOfGroups, 1.0F); groupLayout.setComponentAlignment(groupSizeLabel, Alignment.MIDDLE_LEFT); return groupLayout; } @@ -221,7 +221,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { final HorizontalLayout errorThresoldLayout = new HorizontalLayout(); errorThresoldLayout.setSizeFull(); errorThresoldLayout.addComponents(errorThreshold, errorThresholdOptionGroup); - errorThresoldLayout.setExpandRatio(errorThreshold, 1.0f); + errorThresoldLayout.setExpandRatio(errorThreshold, 1.0F); return errorThresoldLayout; } @@ -229,9 +229,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { final HorizontalLayout targetFilterLayout = new HorizontalLayout(); targetFilterLayout.setSizeFull(); targetFilterLayout.addComponents(targetFilterQueryCombo, targetFilterQuery, totalTargetsLabel); - targetFilterLayout.setExpandRatio(targetFilterQueryCombo, 0.71f); - targetFilterLayout.setExpandRatio(targetFilterQuery, 0.70f); - targetFilterLayout.setExpandRatio(totalTargetsLabel, 0.29f); + targetFilterLayout.setExpandRatio(targetFilterQueryCombo, 0.71F); + targetFilterLayout.setExpandRatio(targetFilterQuery, 0.70F); + targetFilterLayout.setExpandRatio(totalTargetsLabel, 0.29F); targetFilterLayout.setComponentAlignment(totalTargetsLabel, Alignment.MIDDLE_LEFT); return targetFilterLayout; } @@ -240,7 +240,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { final HorizontalLayout triggerThresholdLayout = new HorizontalLayout(); triggerThresholdLayout.setSizeFull(); triggerThresholdLayout.addComponents(triggerThreshold, getPercentHintLabel()); - triggerThresholdLayout.setExpandRatio(triggerThreshold, 1.0f); + triggerThresholdLayout.setExpandRatio(triggerThreshold, 1.0F); return triggerThresholdLayout; } @@ -254,8 +254,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { private HorizontalLayout getSaveDiscardButtonLayout() { final HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSizeFull(); - buttonsLayout.addComponents(saveRollout, discardRolllout); - buttonsLayout.setComponentAlignment(saveRollout, Alignment.BOTTOM_LEFT); + buttonsLayout.addComponents(saveRolloutBtn, discardRolllout); + buttonsLayout.setComponentAlignment(saveRolloutBtn, Alignment.BOTTOM_LEFT); buttonsLayout.setComponentAlignment(discardRolllout, Alignment.BOTTOM_RIGHT); buttonsLayout.addStyleName("window-style"); return buttonsLayout; @@ -277,7 +277,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { description = createDescription(); errorThresholdOptionGroup = createErrorThresholdOptionGroup(); setDefaultSaveStartGroupOption(); - saveRollout = createSaveButton(); + saveRolloutBtn = createSaveButton(); discardRolllout = createDiscardButton(); actionTypeOptionGroupLayout.selectDefaultOption(); @@ -383,8 +383,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { private Container createTargetFilterComboContainer() { final BeanQueryFactory targetFilterQF = new BeanQueryFactory<>( TargetFilterBeanQuery.class); - return new LazyQueryContainer(new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, - SPUILabelDefinitions.VAR_NAME), targetFilterQF); + return new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_NAME), + targetFilterQF); } @@ -410,7 +411,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { } private void onRolloutSave() { - if (editRollout) { + if (editRolloutBtn) { editRollout(); } else { createRollout(); @@ -422,8 +423,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { rolloutForEdit.setName(rolloutName.getValue()); rolloutForEdit.setDescription(description.getValue()); final DistributionSetIdName distributionSetIdName = (DistributionSetIdName) distributionSet.getValue(); - rolloutForEdit.setDistributionSet(distributionSetManagement.findDistributionSetById(distributionSetIdName - .getId())); + rolloutForEdit.setDistributionSet( + distributionSetManagement.findDistributionSetById(distributionSetIdName.getId())); rolloutForEdit.setActionType(getActionType()); rolloutForEdit.setForcedTime(getForcedTimeStamp()); final int amountGroup = Integer.parseInt(noOfGroups.getValue()); @@ -453,8 +454,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { private long getForcedTimeStamp() { return (((ActionTypeOptionGroupLayout.ActionTypeOption) actionTypeOptionGroupLayout.getActionTypeOptionGroup() - .getValue()) == ActionTypeOption.AUTO_FORCED) ? actionTypeOptionGroupLayout.getForcedTimeDateField() - .getValue().getTime() : Action.NO_FORCE_TIME; + .getValue()) == ActionTypeOption.AUTO_FORCED) + ? actionTypeOptionGroupLayout.getForcedTimeDateField().getValue().getTime() + : Action.NO_FORCE_TIME; } private ActionType getActionType() { @@ -487,8 +489,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { rolloutToCreate.setName(rolloutName.getValue()); rolloutToCreate.setDescription(description.getValue()); rolloutToCreate.setTargetFilterQuery(targetFilter); - rolloutToCreate.setDistributionSet(distributionSetManagement.findDistributionSetById(distributionSetIdName - .getId())); + rolloutToCreate + .setDistributionSet(distributionSetManagement.findDistributionSetById(distributionSetIdName.getId())); rolloutToCreate.setActionType(getActionType()); rolloutToCreate.setForcedTime(getForcedTimeStamp()); @@ -499,8 +501,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { private String getTargetFilterQuery() { if (null != targetFilterQueryCombo.getValue() && HawkbitCommonUtil.trimAndNullIfEmpty((String) targetFilterQueryCombo.getValue()) != null) { - final Item filterItem = targetFilterQueryCombo.getContainerDataSource().getItem( - targetFilterQueryCombo.getValue()); + final Item filterItem = targetFilterQueryCombo.getContainerDataSource() + .getItem(targetFilterQueryCombo.getValue()); return (String) filterItem.getItemProperty("query").getValue(); } return null; @@ -568,8 +570,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { private boolean duplicateCheck() { if (rolloutManagement.findRolloutByName(getRolloutName()) != null) { - uiNotification.displayValidationError(i18n.get("message.rollout.duplicate.check", - new Object[] { getRolloutName() })); + uiNotification.displayValidationError( + i18n.get("message.rollout.duplicate.check", new Object[] { getRolloutName() })); return false; } return true; @@ -580,9 +582,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { } private TextArea createDescription() { - final TextArea descriptionField = SPUIComponentProvider.getTextArea("text-area-style", - ValoTheme.TEXTFIELD_TINY, false, null, i18n.get("textfield.description"), - SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH); + final TextArea descriptionField = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTFIELD_TINY, + false, null, i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH); descriptionField.setId(SPUIComponetIdProvider.ROLLOUT_DESCRIPTION_ID); descriptionField.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY); descriptionField.setSizeFull(); @@ -647,8 +648,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { private Container createDsComboContainer() { final BeanQueryFactory distributionQF = new BeanQueryFactory<>(DistBeanQuery.class); - return new LazyQueryContainer(new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, - SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF); + return new LazyQueryContainer( + new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), + distributionQF); } @@ -682,8 +684,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { try { if (HawkbitCommonUtil.trimAndNullIfEmpty(noOfGroups.getValue()) == null || HawkbitCommonUtil.trimAndNullIfEmpty((String) targetFilterQueryCombo.getValue()) == null) { - uiNotification.displayValidationError(i18n - .get("message.rollout.noofgroups.or.targetfilter.missing")); + uiNotification + .displayValidationError(i18n.get("message.rollout.noofgroups.or.targetfilter.missing")); } else { new RegexpValidator(NUMBER_REGEXP, i18n.get(MESSAGE_ENTER_NUMBER)).validate(value); final int groupSize = getGroupSize(); @@ -708,8 +710,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { public void validate(final Object value) { try { new RegexpValidator(NUMBER_REGEXP, i18n.get(MESSAGE_ENTER_NUMBER)).validate(value); - new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 100), 0, 100).validate(Integer - .valueOf(value.toString())); + new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 100), 0, 100) + .validate(Integer.valueOf(value.toString())); } catch (final InvalidValueException ex) { throw ex; } @@ -723,8 +725,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { public void validate(final Object value) { try { new RegexpValidator(NUMBER_REGEXP, i18n.get(MESSAGE_ENTER_NUMBER)).validate(value); - new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 500), 0, 500).validate(Integer - .valueOf(value.toString())); + new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 500), 0, 500) + .validate(Integer.valueOf(value.toString())); } catch (final InvalidValueException ex) { throw ex; } @@ -740,7 +742,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { */ public void populateData(final Long rolloutId) { resetComponents(); - editRollout = Boolean.TRUE; + editRolloutBtn = Boolean.TRUE; rolloutForEdit = rolloutManagement.findRolloutById(rolloutId); rolloutName.setValue(rolloutForEdit.getName()); description.setValue(rolloutForEdit.getDescription()); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java index 6ae002263..20865494b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java @@ -87,7 +87,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac // hide text field until we support multiple gateway tokens for a tenant // MECS-830 gatewayTokenNameTextField.setVisible(false); - gatewayTokenNameTextField.addTextChangeListener(event -> keyNameChanged()); + gatewayTokenNameTextField.addTextChangeListener(event -> doKeyNameChanged()); final Button gatewaytokenBtn = SPUIComponentProvider.getButton("TODO-ID", "Regenerate Key", "", ValoTheme.BUTTON_TINY + " " + "redicon", true, null, SPUIButtonStyleSmall.class); @@ -117,10 +117,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac } } - /** - * @return - */ - private void keyNameChanged() { + private void doKeyNameChanged() { keyNameChanged = true; notifyConfigurationChanged(); } From 7fec5c8407683f240aeb758d4dcc560e84732a6f Mon Sep 17 00:00:00 2001 From: Jonathan Philip Knoblauch Date: Mon, 7 Mar 2016 10:07:06 +0100 Subject: [PATCH 2/7] Changed name saveDistributionButton to saveDistributionBtn and discardDistributionButton to discardDistributionBtn for consistency Signed-off-by: Jonathan Philip Knoblauch --- .../DistributionAddUpdateWindowLayout.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java index 21914778e..9bbc1c05d 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java @@ -94,8 +94,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { @Autowired private transient TenantMetaDataRepository tenantMetaDataRepository; - private Button saveDistributionButton; - private Button discardDistributionButton; + private Button saveDistributionBtn; + private Button discardDistributionBtn; private TextField distNameTextField; private TextField distVersionTextField; private Label madatoryLabel; @@ -131,9 +131,9 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { final HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSizeFull(); buttonsLayout.setStyleName("dist-buttons-horz-layout"); - buttonsLayout.addComponents(saveDistributionButton, discardDistributionButton); - buttonsLayout.setComponentAlignment(saveDistributionButton, Alignment.BOTTOM_LEFT); - buttonsLayout.setComponentAlignment(discardDistributionButton, Alignment.BOTTOM_RIGHT); + buttonsLayout.addComponents(saveDistributionBtn, discardDistributionBtn); + buttonsLayout.setComponentAlignment(saveDistributionBtn, Alignment.BOTTOM_LEFT); + buttonsLayout.setComponentAlignment(discardDistributionBtn, Alignment.BOTTOM_RIGHT); buttonsLayout.addStyleName("window-style"); /* @@ -186,14 +186,14 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { reqMigStepCheckbox.setId(SPUIComponetIdProvider.DIST_ADD_MIGRATION_CHECK); /* save or update button */ - saveDistributionButton = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_SAVE, "", "", "", true, + saveDistributionBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_SAVE, "", "", "", true, FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class); - saveDistributionButton.addClickListener(event -> saveDistribution()); + saveDistributionBtn.addClickListener(event -> saveDistribution()); /* close button */ - discardDistributionButton = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "", + discardDistributionBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "", true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); - discardDistributionButton.addClickListener(event -> discardDistribution()); + discardDistributionBtn.addClickListener(event -> discardDistribution()); } /** @@ -216,7 +216,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { } private void enableSaveButton() { - saveDistributionButton.setEnabled(true); + saveDistributionBtn.setEnabled(true); } private DistributionSetType getDefaultDistributionSetType() { @@ -226,7 +226,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { } private void disableSaveButton() { - saveDistributionButton.setEnabled(false); + saveDistributionBtn.setEnabled(false); } private void saveDistribution() { @@ -415,7 +415,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { distsetTypeNameComboBox.removeStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR); descTextArea.clear(); reqMigStepCheckbox.clear(); - saveDistributionButton.setEnabled(true); + saveDistributionBtn.setEnabled(true); removeListeners(); changedComponents.clear(); } @@ -497,7 +497,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { public void populateValuesOfDistribution(final Long editDistId) { this.editDistId = editDistId; editDistribution = Boolean.TRUE; - saveDistributionButton.setEnabled(false); + saveDistributionBtn.setEnabled(false); final DistributionSet distSet = distributionSetManagement.findDistributionSetByIdWithDetails(editDistId); if (distSet != null) { distNameTextField.setValue(distSet.getName()); From f4791743ce51d6684c9326e39f57310d217848db Mon Sep 17 00:00:00 2001 From: SirWayne Date: Mon, 7 Mar 2016 12:18:18 +0100 Subject: [PATCH 3/7] Add test case description Signed-off-by: SirWayne --- .../eclipse/hawkbit/amqp/BaseAmqpService.java | 1 + .../repository/DeploymentManagementTest.java | 14 +- .../hawkbit/repository/TagManagementTest.java | 124 ++++++++++-------- .../rsql/RSQLDistributionSetFieldTest.java | 2 +- .../resource/SoftwareModuleResourceTest.java | 2 +- .../hawkbit/ui/components/ProxyTarget.java | 22 +--- 6 files changed, 79 insertions(+), 86 deletions(-) diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java index f418937e3..897f1ae62 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java @@ -99,6 +99,7 @@ public class BaseAmqpService { final Object value = header.get(key); if (value == null) { logAndThrowMessageError(message, errorMessageIfNull); + return null; } return value.toString(); } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java index 6427ca8a2..9530a61c3 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java @@ -50,7 +50,6 @@ import com.google.common.eventbus.Subscribe; import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; -import ru.yandex.qatools.allure.annotations.Issue; import ru.yandex.qatools.allure.annotations.Stories; /** @@ -781,12 +780,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { targ = targetManagement.findTargetByControllerID(targ.getControllerId()); - assertEquals(0, deploymentManagement.findActiveActionsByTarget(targ).size()); - assertEquals(1, deploymentManagement.findInActiveActionsByTarget(targ).size()); + assertEquals("active target actions are wrong", 0, deploymentManagement.findActiveActionsByTarget(targ).size()); + assertEquals("active actions are wrong", 1, deploymentManagement.findInActiveActionsByTarget(targ).size()); - assertEquals(TargetUpdateStatus.IN_SYNC, targ.getTargetInfo().getUpdateStatus()); - assertEquals(dsA, targ.getAssignedDistributionSet()); - assertEquals(dsA, targ.getTargetInfo().getInstalledDistributionSet()); + assertEquals("tagret update status is not correct", TargetUpdateStatus.IN_SYNC, + targ.getTargetInfo().getUpdateStatus()); + assertEquals("wrong assigned ds", dsA, targ.getAssignedDistributionSet()); + assertEquals("wrong installed ds", dsA, targ.getTargetInfo().getInstalledDistributionSet()); targs = deploymentManagement.assignDistributionSet(dsB.getId(), new String[] { "target-id-A" }) .getAssignedTargets(); @@ -796,7 +796,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { assertEquals("active actions are wrong", 1, deploymentManagement.findActiveActionsByTarget(targ).size()); assertEquals("target status is wrong", TargetUpdateStatus.PENDING, targetManagement.findTargetByControllerID(targ.getControllerId()).getTargetInfo().getUpdateStatus()); - assertEquals(dsB, targ.getAssignedDistributionSet()); + assertEquals("wrong assigned ds", dsB, targ.getAssignedDistributionSet()); assertEquals("Installed ds is wrong", dsA.getId(), targetManagement.findTargetByControllerIDWithDetails(targ.getControllerId()).getTargetInfo() .getInstalledDistributionSet().getId()); diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java index b8a4db598..b1c2cf3e3 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java @@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository; import static org.fest.assertions.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import java.util.List; @@ -22,6 +23,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.Tag; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetTag; +import org.junit.Before; import org.junit.Test; import org.slf4j.LoggerFactory; @@ -42,6 +44,11 @@ public class TagManagementTest extends AbstractIntegrationTest { LOG = LoggerFactory.getLogger(TagManagementTest.class); } + @Before + public void setup() { + assertThat(targetTagRepository.findAll()).as("Not tags should be available").isEmpty(); + } + @Test @Description("Full DS tag lifecycle tested. Create tags, assign them to sets and delete the tags.") public void createAndAssignAndDeleteDistributionSetTags() { @@ -88,7 +95,7 @@ public class TagManagementTest extends AbstractIntegrationTest { // search for not deleted distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true) .setTagNames(Lists.newArrayList(tagA.getName())); - assertEquals( + assertEquals("filter works not correct", dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) @@ -96,7 +103,7 @@ public class TagManagementTest extends AbstractIntegrationTest { distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true) .setTagNames(Lists.newArrayList(tagB.getName())); - assertEquals( + assertEquals("filter works not correct", dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) @@ -104,7 +111,7 @@ public class TagManagementTest extends AbstractIntegrationTest { distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true) .setTagNames(Lists.newArrayList(tagC.getName())); - assertEquals( + assertEquals("filter works not correct", dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown() + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) @@ -112,22 +119,22 @@ public class TagManagementTest extends AbstractIntegrationTest { distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true) .setTagNames(Lists.newArrayList(tagX.getName())); - assertEquals(0, distributionSetManagement + assertEquals("filter works not correct", 0, distributionSetManagement .findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements()); - assertEquals(5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown()); + assertEquals("wrong tag size", 5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown()); tagManagement.deleteDistributionSetTag(tagY.getName()); - assertEquals(4, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown()); + assertEquals("wrong tag size", 4, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown()); tagManagement.deleteDistributionSetTag(tagX.getName()); - assertEquals(3, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown()); + assertEquals("wrong tag size", 3, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown()); tagManagement.deleteDistributionSetTag(tagB.getName()); - assertEquals(2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown()); + assertEquals("wrong tag size", 2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown()); distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE) .setTagNames(Lists.newArrayList(tagA.getName())); - assertEquals( + assertEquals("filter works not correct", dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) @@ -135,12 +142,12 @@ public class TagManagementTest extends AbstractIntegrationTest { distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE) .setTagNames(Lists.newArrayList(tagB.getName())); - assertEquals(0, distributionSetManagement + assertEquals("filter works not correct", 0, distributionSetManagement .findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements()); distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE) .setTagNames(Lists.newArrayList(tagC.getName())); - assertEquals( + assertEquals("filter works not correct", dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown() + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) @@ -154,30 +161,27 @@ public class TagManagementTest extends AbstractIntegrationTest { @Test @Description("Ensures that all tags are retrieved through repository.") public void findAllTargetTags() { - assertThat(targetTagRepository.findAll()).isEmpty(); - final List tags = createTargetsWithTags(); assertThat(targetTagRepository.findAll()).isEqualTo(tagManagement.findAllTargetTags()).isEqualTo(tags) - .hasSize(20); + .as("Wrong tag size").hasSize(20); } @Test @Description("Ensures that a created tag is persisted in the repository as defined.") public void createTargetTag() { - assertThat(targetTagRepository.findAll()).isEmpty(); - final Tag tag = tagManagement.createTargetTag(new TargetTag("kai1", "kai2", "colour")); - assertThat(targetTagRepository.findByNameEquals("kai1").getDescription()).isEqualTo("kai2"); - assertThat(tagManagement.findTargetTag("kai1").getColour()).isEqualTo("colour"); - assertThat(tagManagement.findTargetTagById(tag.getId()).getColour()).isEqualTo("colour"); + assertThat(targetTagRepository.findByNameEquals("kai1").getDescription()).as("wrong tag founded") + .isEqualTo("kai2"); + assertThat(tagManagement.findTargetTag("kai1").getColour()).as("wrong tag founded").isEqualTo("colour"); + assertThat(tagManagement.findTargetTagById(tag.getId()).getColour()).as("wrong tag founded") + .isEqualTo("colour"); } @Test @Description("Ensures that a deleted tag is removed from the repository as defined.") public void deleteTargetTas() { - assertThat(targetTagRepository.findAll()).isEmpty(); // create test data final Iterable tags = createTargetsWithTags(); @@ -196,16 +200,13 @@ public class TagManagementTest extends AbstractIntegrationTest { assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getTags()) .doesNotContain(toDelete); } - assertThat(targetTagRepository.findOne(toDelete.getId())).isNull(); - assertThat(tagManagement.findAllTargetTags()).hasSize(19); + assertThat(targetTagRepository.findOne(toDelete.getId())).as("No tag should be founded").isNull(); + assertThat(tagManagement.findAllTargetTags()).as("Wrong target tag size").hasSize(19); } @Test @Description("Tests the name update of a target tag.") public void updateTargetTag() { - assertThat(targetTagRepository.findAll()).isEmpty(); - - // create test data final List tags = createTargetsWithTags(); // change data @@ -216,95 +217,105 @@ public class TagManagementTest extends AbstractIntegrationTest { tagManagement.updateTargetTag(savedAssigned); // check data - assertThat(tagManagement.findAllTargetTags()).hasSize(tags.size()); - assertThat(targetTagRepository.findOne(savedAssigned.getId()).getName()).isEqualTo("test123"); - assertThat(targetTagRepository.findOne(savedAssigned.getId()).getOptLockRevision()).isEqualTo(2); + assertThat(tagManagement.findAllTargetTags()).as("Wrong target tag size").hasSize(tags.size()); + assertThat(targetTagRepository.findOne(savedAssigned.getId()).getName()).as("wrong target tag is saved") + .isEqualTo("test123"); + assertThat(targetTagRepository.findOne(savedAssigned.getId()).getOptLockRevision()) + .as("wrong target tag is saved").isEqualTo(2); } @Test @Description("Ensures that a created tag is persisted in the repository as defined.") public void createDistributionSetTag() { - assertThat(distributionSetTagRepository.findAll()).isEmpty(); - final Tag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("kai1", "kai2", "colour")); - assertThat(distributionSetTagRepository.findByNameEquals("kai1").getDescription()).isEqualTo("kai2"); - assertThat(tagManagement.findDistributionSetTag("kai1").getColour()).isEqualTo("colour"); - assertThat(tagManagement.findDistributionSetTagById(tag.getId()).getColour()).isEqualTo("colour"); + assertThat(distributionSetTagRepository.findByNameEquals("kai1").getDescription()).as("wrong tag founded") + .isEqualTo("kai2"); + assertThat(tagManagement.findDistributionSetTag("kai1").getColour()).as("wrong tag founded") + .isEqualTo("colour"); + assertThat(tagManagement.findDistributionSetTagById(tag.getId()).getColour()).as("wrong tag founded") + .isEqualTo("colour"); } @Test @Description("Ensures that a created tags are persisted in the repository as defined.") public void createDistributionSetTags() { - assertThat(distributionSetTagRepository.findAll()).isEmpty(); - final List tags = createDsSetsWithTags(); - assertThat(distributionSetTagRepository.findAll()).hasSize(tags.size()); + assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags created").hasSize(tags.size()); } @Test @Description("Ensures that a deleted tag is removed from the repository as defined.") public void deleteDistributionSetTag() { - assertThat(distributionSetTagRepository.findAll()).isEmpty(); - // create test data final Iterable tags = createDsSetsWithTags(); final DistributionSetTag toDelete = tags.iterator().next(); for (final DistributionSet set : distributionSetRepository.findAll()) { assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags()) - .contains(toDelete); + .as("Wrong tag founded").contains(toDelete); } // delete tagManagement.deleteDistributionSetTag(tags.iterator().next().getName()); // check - assertThat(distributionSetTagRepository.findOne(toDelete.getId())).isNull(); - assertThat(tagManagement.findAllDistributionSetTags()).hasSize(19); + assertThat(distributionSetTagRepository.findOne(toDelete.getId())).as("Deleted tag should be null").isNull(); + assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of tags after deletion").hasSize(19); for (final DistributionSet set : distributionSetRepository.findAll()) { assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags()) - .doesNotContain(toDelete); + .as("Wrong founded tags").doesNotContain(toDelete); } } - @Test(expected = EntityAlreadyExistsException.class) @Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).") public void failedDuplicateTargetTagNameException() { tagManagement.createTargetTag(new TargetTag("A")); - tagManagement.createTargetTag(new TargetTag("A")); + try { + tagManagement.createTargetTag(new TargetTag("A")); + fail("Excpeted EntityAlreadyExistsException"); + } catch (final EntityAlreadyExistsException e) { + } } - @Test(expected = EntityAlreadyExistsException.class) @Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).") public void failedDuplicateTargetTagNameExceptionAfterUpdate() { tagManagement.createTargetTag(new TargetTag("A")); final TargetTag tag = tagManagement.createTargetTag(new TargetTag("B")); tag.setName("A"); - tagManagement.updateTargetTag(tag); + try { + tagManagement.updateTargetTag(tag); + fail("Excpeted EntityAlreadyExistsException"); + } catch (final EntityAlreadyExistsException e) { + } } - @Test(expected = EntityAlreadyExistsException.class) @Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).") public void failedDuplicateDsTagNameException() { tagManagement.createDistributionSetTag(new DistributionSetTag("A")); - tagManagement.createDistributionSetTag(new DistributionSetTag("A")); + try { + tagManagement.createDistributionSetTag(new DistributionSetTag("A")); + fail("Excpeted EntityAlreadyExistsException"); + } catch (final EntityAlreadyExistsException e) { + } } - @Test(expected = EntityAlreadyExistsException.class) @Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).") public void failedDuplicateDsTagNameExceptionAfterUpdate() { tagManagement.createDistributionSetTag(new DistributionSetTag("A")); final DistributionSetTag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("B")); tag.setName("A"); - tagManagement.updateDistributionSetTag(tag); + try { + tagManagement.updateDistributionSetTag(tag); + fail("Excpeted EntityAlreadyExistsException"); + } catch (final EntityAlreadyExistsException e) { + } } @Test @Description("Tests the name update of a target tag.") public void updateDistributionSetTag() { - assertThat(distributionSetTagRepository.findAll()).isEmpty(); // create test data final List tags = createDsSetsWithTags(); @@ -317,20 +328,19 @@ public class TagManagementTest extends AbstractIntegrationTest { tagManagement.updateDistributionSetTag(savedAssigned); // check data - assertThat(tagManagement.findAllDistributionSetTags()).hasSize(tags.size()); - assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).isEqualTo("test123"); + assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of ds tags").hasSize(tags.size()); + assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).as("Wrong ds tag founded") + .isEqualTo("test123"); } @Test @Description("Ensures that all tags are retrieved through repository.") public void findDistributionSetTagsAll() { - assertThat(distributionSetTagRepository.findAll()).isEmpty(); - final List tags = createDsSetsWithTags(); // test - assertThat(tagManagement.findAllDistributionSetTags()).hasSize(tags.size()); - assertThat(distributionSetTagRepository.findAll()).hasSize(20); + assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of tags").hasSize(tags.size()); + assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags").hasSize(20); } private List createTargetsWithTags() { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetFieldTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetFieldTest.java index 40d757d15..add5419ee 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetFieldTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetFieldTest.java @@ -98,7 +98,7 @@ public class RSQLDistributionSetFieldTest extends AbstractIntegrationTest { assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "==true", 4); try { assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "==noExist*", 0); - fail(); + fail("Excepted RSQLParameterSyntaxException"); } catch (final RSQLParameterSyntaxException e) { } assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "=in=(true)", 4); diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java index cf93fcba7..0b8503d6b 100644 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java @@ -311,7 +311,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo .andExpect(header().string("ETag", artifact.getSha1Hash())) .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)).andReturn(); - assertTrue(Arrays.equals(result.getResponse().getContentAsByteArray(), random)); + assertTrue("Wrong response content", Arrays.equals(result.getResponse().getContentAsByteArray(), random)); final MvcResult result2 = mvc .perform(get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", sm.getId(), diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java index 9a374f980..d85b2bc71 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java @@ -38,11 +38,9 @@ public class ProxyTarget extends Target { private TargetIdName targetIdName; - private Long createdAt; + private String assignedDistNameVersion; - private String assignedDistNameVersion = null; - - private String installedDistNameVersion = null; + private String installedDistNameVersion; private String pollStatusToolTip; @@ -251,22 +249,6 @@ public class ProxyTarget extends Target { this.installedDistributionSet = installedDistributionSet; } - /** - * @return the createdAt - */ - @Override - public Long getCreatedAt() { - return createdAt; - } - - /** - * @param createdAt - * the createdAt to set - */ - public void setCreatedAt(final Long createdAt) { - this.createdAt = createdAt; - } - /** * @return the targetIdName */ From cf48ef215a0f81a8744e63c22531691f8fefcbe8 Mon Sep 17 00:00:00 2001 From: Jonathan Philip Knoblauch Date: Mon, 7 Mar 2016 13:14:40 +0100 Subject: [PATCH 4/7] Changed names for editRollout boolean and discardRolllout Button Signed-off-by: Jonathan Philip Knoblauch --- .../ui/rollout/AddUpdateRolloutWindowLayout.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/AddUpdateRolloutWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/AddUpdateRolloutWindowLayout.java index 3a1deaf65..cdcbbcede 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/AddUpdateRolloutWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/AddUpdateRolloutWindowLayout.java @@ -130,7 +130,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { private Button saveRolloutBtn; - private Button discardRolllout; + private Button discardRollloutBtn; private OptionGroup errorThresholdOptionGroup; @@ -138,7 +138,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { private Window addUpdateRolloutWindow; - private Boolean editRolloutBtn; + private Boolean editRolloutEnabled; private Rollout rolloutForEdit; @@ -167,7 +167,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { * Reset the field values. */ public void resetComponents() { - editRolloutBtn = Boolean.FALSE; + editRolloutEnabled = Boolean.FALSE; rolloutName.clear(); targetFilterQuery.clear(); resetFields(); @@ -254,9 +254,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { private HorizontalLayout getSaveDiscardButtonLayout() { final HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSizeFull(); - buttonsLayout.addComponents(saveRolloutBtn, discardRolllout); + buttonsLayout.addComponents(saveRolloutBtn, discardRollloutBtn); buttonsLayout.setComponentAlignment(saveRolloutBtn, Alignment.BOTTOM_LEFT); - buttonsLayout.setComponentAlignment(discardRolllout, Alignment.BOTTOM_RIGHT); + buttonsLayout.setComponentAlignment(discardRollloutBtn, Alignment.BOTTOM_RIGHT); buttonsLayout.addStyleName("window-style"); return buttonsLayout; } @@ -278,7 +278,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { errorThresholdOptionGroup = createErrorThresholdOptionGroup(); setDefaultSaveStartGroupOption(); saveRolloutBtn = createSaveButton(); - discardRolllout = createDiscardButton(); + discardRollloutBtn = createDiscardButton(); actionTypeOptionGroupLayout.selectDefaultOption(); totalTargetsLabel = createTotalTargetsLabel(); @@ -411,7 +411,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { } private void onRolloutSave() { - if (editRolloutBtn) { + if (editRolloutEnabled) { editRollout(); } else { createRollout(); @@ -742,7 +742,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent { */ public void populateData(final Long rolloutId) { resetComponents(); - editRolloutBtn = Boolean.TRUE; + editRolloutEnabled = Boolean.TRUE; rolloutForEdit = rolloutManagement.findRolloutById(rolloutId); rolloutName.setValue(rolloutForEdit.getName()); description.setValue(rolloutForEdit.getDescription()); From 43d01da309f2d81b62fc29a46cb7ccfa00e3317d Mon Sep 17 00:00:00 2001 From: SirWayne Date: Mon, 7 Mar 2016 13:35:26 +0100 Subject: [PATCH 5/7] Fix typo after pull request review Signed-off-by: SirWayne --- .../hawkbit/repository/TagManagementTest.java | 31 +++++++++---------- .../rsql/RSQLDistributionSetFieldTest.java | 2 +- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java index b1c2cf3e3..eb263b242 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java @@ -172,11 +172,9 @@ public class TagManagementTest extends AbstractIntegrationTest { public void createTargetTag() { final Tag tag = tagManagement.createTargetTag(new TargetTag("kai1", "kai2", "colour")); - assertThat(targetTagRepository.findByNameEquals("kai1").getDescription()).as("wrong tag founded") - .isEqualTo("kai2"); - assertThat(tagManagement.findTargetTag("kai1").getColour()).as("wrong tag founded").isEqualTo("colour"); - assertThat(tagManagement.findTargetTagById(tag.getId()).getColour()).as("wrong tag founded") - .isEqualTo("colour"); + assertThat(targetTagRepository.findByNameEquals("kai1").getDescription()).as("wrong tag ed").isEqualTo("kai2"); + assertThat(tagManagement.findTargetTag("kai1").getColour()).as("wrong tag found").isEqualTo("colour"); + assertThat(tagManagement.findTargetTagById(tag.getId()).getColour()).as("wrong tag found").isEqualTo("colour"); } @Test @@ -200,7 +198,7 @@ public class TagManagementTest extends AbstractIntegrationTest { assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getTags()) .doesNotContain(toDelete); } - assertThat(targetTagRepository.findOne(toDelete.getId())).as("No tag should be founded").isNull(); + assertThat(targetTagRepository.findOne(toDelete.getId())).as("No tag should be found").isNull(); assertThat(tagManagement.findAllTargetTags()).as("Wrong target tag size").hasSize(19); } @@ -229,11 +227,10 @@ public class TagManagementTest extends AbstractIntegrationTest { public void createDistributionSetTag() { final Tag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("kai1", "kai2", "colour")); - assertThat(distributionSetTagRepository.findByNameEquals("kai1").getDescription()).as("wrong tag founded") + assertThat(distributionSetTagRepository.findByNameEquals("kai1").getDescription()).as("wrong tag found") .isEqualTo("kai2"); - assertThat(tagManagement.findDistributionSetTag("kai1").getColour()).as("wrong tag founded") - .isEqualTo("colour"); - assertThat(tagManagement.findDistributionSetTagById(tag.getId()).getColour()).as("wrong tag founded") + assertThat(tagManagement.findDistributionSetTag("kai1").getColour()).as("wrong tag found").isEqualTo("colour"); + assertThat(tagManagement.findDistributionSetTagById(tag.getId()).getColour()).as("wrong tag found") .isEqualTo("colour"); } @@ -254,7 +251,7 @@ public class TagManagementTest extends AbstractIntegrationTest { for (final DistributionSet set : distributionSetRepository.findAll()) { assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags()) - .as("Wrong tag founded").contains(toDelete); + .as("Wrong tag found").contains(toDelete); } // delete @@ -265,7 +262,7 @@ public class TagManagementTest extends AbstractIntegrationTest { assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of tags after deletion").hasSize(19); for (final DistributionSet set : distributionSetRepository.findAll()) { assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags()) - .as("Wrong founded tags").doesNotContain(toDelete); + .as("Wrong found tags").doesNotContain(toDelete); } } @@ -274,7 +271,7 @@ public class TagManagementTest extends AbstractIntegrationTest { tagManagement.createTargetTag(new TargetTag("A")); try { tagManagement.createTargetTag(new TargetTag("A")); - fail("Excpeted EntityAlreadyExistsException"); + fail("Expected EntityAlreadyExistsException"); } catch (final EntityAlreadyExistsException e) { } } @@ -286,7 +283,7 @@ public class TagManagementTest extends AbstractIntegrationTest { tag.setName("A"); try { tagManagement.updateTargetTag(tag); - fail("Excpeted EntityAlreadyExistsException"); + fail("Expected EntityAlreadyExistsException"); } catch (final EntityAlreadyExistsException e) { } } @@ -296,7 +293,7 @@ public class TagManagementTest extends AbstractIntegrationTest { tagManagement.createDistributionSetTag(new DistributionSetTag("A")); try { tagManagement.createDistributionSetTag(new DistributionSetTag("A")); - fail("Excpeted EntityAlreadyExistsException"); + fail("Expected EntityAlreadyExistsException"); } catch (final EntityAlreadyExistsException e) { } } @@ -308,7 +305,7 @@ public class TagManagementTest extends AbstractIntegrationTest { tag.setName("A"); try { tagManagement.updateDistributionSetTag(tag); - fail("Excpeted EntityAlreadyExistsException"); + fail("Expected EntityAlreadyExistsException"); } catch (final EntityAlreadyExistsException e) { } } @@ -329,7 +326,7 @@ public class TagManagementTest extends AbstractIntegrationTest { // check data assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of ds tags").hasSize(tags.size()); - assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).as("Wrong ds tag founded") + assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).as("Wrong ds tag found") .isEqualTo("test123"); } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetFieldTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetFieldTest.java index add5419ee..ea1db0ed8 100644 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetFieldTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/rsql/RSQLDistributionSetFieldTest.java @@ -98,7 +98,7 @@ public class RSQLDistributionSetFieldTest extends AbstractIntegrationTest { assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "==true", 4); try { assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "==noExist*", 0); - fail("Excepted RSQLParameterSyntaxException"); + fail("Expected RSQLParameterSyntaxException"); } catch (final RSQLParameterSyntaxException e) { } assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "=in=(true)", 4); From 6c74c1186dbd95bc57ac1661ffc3e863d81c1b9f Mon Sep 17 00:00:00 2001 From: SirWayne Date: Tue, 8 Mar 2016 12:23:31 +0100 Subject: [PATCH 6/7] Create unit test for the json amqp message conversion Signed-off-by: SirWayne --- .../eclipse/hawkbit/amqp/BaseAmqpService.java | 8 +- .../amqp/AmqpMessageHandlerServiceTest.java | 1 + .../hawkbit/amqp/BaseAmqpServiceTest.java | 103 ++++++++++++++++++ 3 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java index 897f1ae62..8a054165b 100644 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/BaseAmqpService.java @@ -58,8 +58,8 @@ public class BaseAmqpService { * @return the converted object */ @SuppressWarnings("unchecked") - protected T convertMessage(final Message message, final Class clazz) { - if (message == null) { + public T convertMessage(final Message message, final Class clazz) { + if (message == null || message.getBody() == null) { return null; } message.getMessageProperties().getHeaders().put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME, @@ -78,8 +78,8 @@ public class BaseAmqpService { * @return the list of converted objects */ @SuppressWarnings("unchecked") - protected List convertMessageList(final Message message, final Class clazz) { - if (message == null) { + public List convertMessageList(final Message message, final Class clazz) { + if (message == null || message.getBody() == null) { return Collections.emptyList(); } message.getMessageProperties().getHeaders().put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME, diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java index 79a39a40a..9d6ae3ba7 100644 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java @@ -116,6 +116,7 @@ public class AmqpMessageHandlerServiceTest { } + @Test @Description("Tests not allowed content-type in message") public void testWrongContentType() { final MessageProperties messageProperties = new MessageProperties(); diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java new file mode 100644 index 000000000..0bd8c164b --- /dev/null +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2015 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.amqp; + +import static org.fest.assertions.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.hawkbit.dmf.json.model.ActionUpdateStatus; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessageProperties; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; + +import ru.yandex.qatools.allure.annotations.Description; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@RunWith(MockitoJUnitRunner.class) +@Features("Component Tests - Device Management Federation API") +@Stories("Base Amqp Service Test") +public class BaseAmqpServiceTest { + + @Mock + private RabbitTemplate rabbitTemplate; + + private BaseAmqpService baseAmqpService; + + @Before + public void setup() { + when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter()); + baseAmqpService = new BaseAmqpService(rabbitTemplate); + + } + + @Test + @Description("Verify that the message conversion works") + public void convertMessageTest() { + final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus(); + actionUpdateStatus.setActionId(1L); + actionUpdateStatus.setSoftwareModuleId(2L); + + final Message message = rabbitTemplate.getMessageConverter().toMessage(actionUpdateStatus, + new MessageProperties()); + ActionUpdateStatus convertedActionUpdateStatus = baseAmqpService.convertMessage(message, + ActionUpdateStatus.class); + + assertThat(convertedActionUpdateStatus).as("Converted Action Status is wrong") + .isEqualsToByComparingFields(actionUpdateStatus); + + convertedActionUpdateStatus = baseAmqpService.convertMessage(null, ActionUpdateStatus.class); + assertThat(convertedActionUpdateStatus).as("Converted Object should be null when message is null").isNull(); + + convertedActionUpdateStatus = baseAmqpService.convertMessage(new Message(null, new MessageProperties()), + ActionUpdateStatus.class); + assertThat(convertedActionUpdateStatus).as("Converted Object should be null when message body is null") + .isNull(); + } + + @Test + @Description("Verify that a conversion of a list from a message works") + public void convertMessageListTest() { + final List actionUpdateStatusList = new ArrayList<>(); + for (int i = 0; i < 5; i++) { + final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus(); + actionUpdateStatus.setActionId(Long.valueOf(i)); + actionUpdateStatus.setSoftwareModuleId(Long.valueOf(i)); + actionUpdateStatusList.add(actionUpdateStatus); + } + + final Message message = rabbitTemplate.getMessageConverter().toMessage(actionUpdateStatusList, + new MessageProperties()); + List convertedActionUpdateStatus = baseAmqpService.convertMessageList(message, + ActionUpdateStatus.class); + + assertThat(convertedActionUpdateStatus).as("Converted Action Status list is wrong") + .hasSameClassAs(actionUpdateStatusList); + assertThat(convertedActionUpdateStatus).as("Converted Action Status list is wrong") + .hasSameSizeAs(actionUpdateStatusList); + + convertedActionUpdateStatus = baseAmqpService.convertMessageList(null, ActionUpdateStatus.class); + assertThat(convertedActionUpdateStatus).as("Converted list should be empty when message is null").isEmpty(); + + convertedActionUpdateStatus = baseAmqpService.convertMessageList(new Message(null, new MessageProperties()), + ActionUpdateStatus.class); + assertThat(convertedActionUpdateStatus).as("Converted list should be empty when message body is null") + .isEmpty(); + } + +} From dd7f7d2a9dc8224943502338d09cf6b6e1a52ca8 Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Tue, 8 Mar 2016 17:39:24 +0100 Subject: [PATCH 7/7] fix mgmt client startup with xml problem and not unique bean exception Signed-off-by: Michael Hirsch --- .../hawkbit/mgmt/client/ClientConfigurationProperties.java | 2 -- .../hawkbit-mgmt-api-client/src/main/resources/logback.xml | 3 --- 2 files changed, 5 deletions(-) diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/ClientConfigurationProperties.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/ClientConfigurationProperties.java index ead019247..68f35b550 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/ClientConfigurationProperties.java +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/client/ClientConfigurationProperties.java @@ -9,14 +9,12 @@ package org.eclipse.hawkbit.mgmt.client; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; /** * Configuration bean which holds the configuration of the client e.g. the base * URL of the hawkbit-server and the credentials to use the RESTful Management * API. */ -@Component @ConfigurationProperties(prefix = "hawkbit") public class ClientConfigurationProperties { diff --git a/examples/hawkbit-mgmt-api-client/src/main/resources/logback.xml b/examples/hawkbit-mgmt-api-client/src/main/resources/logback.xml index 819566e0f..0174611e6 100644 --- a/examples/hawkbit-mgmt-api-client/src/main/resources/logback.xml +++ b/examples/hawkbit-mgmt-api-client/src/main/resources/logback.xml @@ -1,6 +1,3 @@ -