Code cleanup (#427)

* Removed dead code.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix sonar issues.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-01-30 11:10:46 +01:00
committed by GitHub
parent d553716cda
commit 59f218e841
54 changed files with 141 additions and 1137 deletions

View File

@@ -10,8 +10,10 @@ package org.eclipse.hawkbit.amqp;
import java.util.concurrent.TimeUnit;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.InvalidTargetAddressException;
import org.eclipse.hawkbit.repository.exception.TenantNotExistException;
import org.eclipse.hawkbit.repository.exception.ToManyAttributeEntriesException;
import org.eclipse.hawkbit.repository.exception.TooManyStatusEntriesException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,8 +42,7 @@ public class DelayedRequeueExceptionStrategy extends ConditionalRejectingErrorHa
@Override
protected boolean isUserCauseFatal(final Throwable cause) {
if (cause instanceof TenantNotExistException || cause instanceof TooManyStatusEntriesException
|| cause instanceof InvalidTargetAddressException) {
if (invalidMessage(cause)) {
return true;
}
@@ -56,4 +57,13 @@ public class DelayedRequeueExceptionStrategy extends ConditionalRejectingErrorHa
return false;
}
private boolean invalidMessage(final Throwable cause) {
return doesNotExist(cause) || cause instanceof TooManyStatusEntriesException
|| cause instanceof InvalidTargetAddressException || cause instanceof ToManyAttributeEntriesException;
}
private boolean doesNotExist(final Throwable cause) {
return cause instanceof TenantNotExistException || cause instanceof EntityNotFoundException;
}
}

View File

@@ -61,7 +61,7 @@ public final class MgmtDistributionSetMapper {
* to convert
* @return converted {@link DistributionSet}
*/
static DistributionSetCreate fromRequest(final MgmtDistributionSetRequestBodyPost dsRest,
private static DistributionSetCreate fromRequest(final MgmtDistributionSetRequestBodyPost dsRest,
final EntityFactory entityFactory) {
final List<Long> modules = new ArrayList<>();
@@ -97,14 +97,7 @@ public final class MgmtDistributionSetMapper {
.collect(Collectors.toList());
}
/**
* Create a response for distribution set.
*
* @param distributionSet
* the ds set
* @return the response
*/
public static MgmtDistributionSet toResponse(final DistributionSet distributionSet) {
static MgmtDistributionSet toResponse(final DistributionSet distributionSet) {
if (distributionSet == null) {
return null;
}

View File

@@ -47,7 +47,7 @@ final class MgmtDistributionSetTypeMapper {
return smTypesRest.stream().map(smRest -> fromRequest(entityFactory, smRest)).collect(Collectors.toList());
}
static DistributionSetTypeCreate fromRequest(final EntityFactory entityFactory,
private static DistributionSetTypeCreate fromRequest(final EntityFactory entityFactory,
final MgmtDistributionSetTypeRequestBodyPost smsRest) {
return entityFactory.distributionSetType().create().key(smsRest.getKey()).name(smsRest.getName())
.description(smsRest.getDescription()).colour(smsRest.getColour())

View File

@@ -186,56 +186,56 @@ final class MgmtRolloutMapper {
return body;
}
static RolloutGroupErrorCondition mapErrorCondition(final Condition condition) {
private static RolloutGroupErrorCondition mapErrorCondition(final Condition condition) {
if (Condition.THRESHOLD.equals(condition)) {
return RolloutGroupErrorCondition.THRESHOLD;
}
throw new IllegalArgumentException(createIllegalArgumentLiteral(condition));
}
static RolloutGroupSuccessCondition mapFinishCondition(final Condition condition) {
private static RolloutGroupSuccessCondition mapFinishCondition(final Condition condition) {
if (Condition.THRESHOLD.equals(condition)) {
return RolloutGroupSuccessCondition.THRESHOLD;
}
throw new IllegalArgumentException(createIllegalArgumentLiteral(condition));
}
static Condition map(final RolloutGroupSuccessCondition rolloutCondition) {
private static Condition map(final RolloutGroupSuccessCondition rolloutCondition) {
if (RolloutGroupSuccessCondition.THRESHOLD.equals(rolloutCondition)) {
return Condition.THRESHOLD;
}
throw new IllegalArgumentException("Rollout group condition " + rolloutCondition + NOT_SUPPORTED);
}
static Condition map(final RolloutGroupErrorCondition rolloutCondition) {
private static Condition map(final RolloutGroupErrorCondition rolloutCondition) {
if (RolloutGroupErrorCondition.THRESHOLD.equals(rolloutCondition)) {
return Condition.THRESHOLD;
}
throw new IllegalArgumentException("Rollout group condition " + rolloutCondition + NOT_SUPPORTED);
}
static RolloutGroupErrorAction map(final ErrorAction action) {
private static RolloutGroupErrorAction map(final ErrorAction action) {
if (ErrorAction.PAUSE.equals(action)) {
return RolloutGroupErrorAction.PAUSE;
}
throw new IllegalArgumentException("Error Action " + action + NOT_SUPPORTED);
}
static RolloutGroupSuccessAction map(final SuccessAction action) {
private static RolloutGroupSuccessAction map(final SuccessAction action) {
if (SuccessAction.NEXTGROUP.equals(action)) {
return RolloutGroupSuccessAction.NEXTGROUP;
}
throw new IllegalArgumentException("Success Action " + action + NOT_SUPPORTED);
}
static SuccessAction map(final RolloutGroupSuccessAction successAction) {
private static SuccessAction map(final RolloutGroupSuccessAction successAction) {
if (RolloutGroupSuccessAction.NEXTGROUP.equals(successAction)) {
return SuccessAction.NEXTGROUP;
}
throw new IllegalArgumentException("Rollout group success action " + successAction + NOT_SUPPORTED);
}
static ErrorAction map(final RolloutGroupErrorAction errorAction) {
private static ErrorAction map(final RolloutGroupErrorAction errorAction) {
if (RolloutGroupErrorAction.PAUSE.equals(errorAction)) {
return ErrorAction.PAUSE;
}

View File

@@ -42,7 +42,7 @@ public final class MgmtSoftwareModuleMapper {
// Utility class
}
static SoftwareModuleCreate fromRequest(final EntityFactory entityFactory,
private static SoftwareModuleCreate fromRequest(final EntityFactory entityFactory,
final MgmtSoftwareModuleRequestBodyPost smsRest) {
return entityFactory.softwareModule().create().type(smsRest.getType()).name(smsRest.getName())
.version(smsRest.getVersion()).description(smsRest.getDescription()).vendor(smsRest.getVendor());
@@ -68,14 +68,7 @@ public final class MgmtSoftwareModuleMapper {
return smsRest.stream().map(smRest -> fromRequest(entityFactory, smRest)).collect(Collectors.toList());
}
/**
* Create response for sw modules.
*
* @param softwareModules
* the modules
* @return the response
*/
public static List<MgmtSoftwareModule> toResponse(final Collection<SoftwareModule> softwareModules) {
static List<MgmtSoftwareModule> toResponse(final Collection<SoftwareModule> softwareModules) {
if (softwareModules == null) {
return Collections.emptyList();
}
@@ -99,14 +92,7 @@ public final class MgmtSoftwareModuleMapper {
return metadataRest;
}
/**
* Create response for one sw module.
*
* @param baseSofwareModule
* the sw module
* @return the response
*/
public static MgmtSoftwareModule toResponse(final SoftwareModule baseSofwareModule) {
static MgmtSoftwareModule toResponse(final SoftwareModule baseSofwareModule) {
if (baseSofwareModule == null) {
return null;
}

View File

@@ -45,7 +45,7 @@ final class MgmtSoftwareModuleTypeMapper {
return smTypesRest.stream().map(smRest -> fromRequest(entityFactory, smRest)).collect(Collectors.toList());
}
static SoftwareModuleTypeCreate fromRequest(final EntityFactory entityFactory,
private static SoftwareModuleTypeCreate fromRequest(final EntityFactory entityFactory,
final MgmtSoftwareModuleTypeRequestBodyPost smsRest) {
return entityFactory.softwareModuleType().create().key(smsRest.getKey()).name(smsRest.getName())
.description(smsRest.getDescription()).colour(smsRest.getColour())

View File

@@ -30,14 +30,7 @@ public final class MgmtSystemMapper {
// Utility class
}
/**
* @param tenantConfigurationManagement
* instance of TenantConfigurationManagement
* @param tenantConfigurationProperties
* to get defined keys
* @return a map of all existing configuration values
*/
public static Map<String, MgmtSystemTenantConfigurationValue> toResponse(
static Map<String, MgmtSystemTenantConfigurationValue> toResponse(
final TenantConfigurationManagement tenantConfigurationManagement,
final TenantConfigurationProperties tenantConfigurationProperties) {
@@ -46,17 +39,7 @@ public final class MgmtSystemMapper {
tenantConfigurationManagement.getConfigurationValue(key.getKeyName()))));
}
/**
* maps a TenantConfigurationValue from the repository model to a
* MgmtSystemTenantConfigurationValue, the RESTful model.
*
* @param key
* the key
* @param repoConfValue
* configuration value as repository model
* @return configuration value as RESTful model
*/
public static MgmtSystemTenantConfigurationValue toResponse(final String key,
static MgmtSystemTenantConfigurationValue toResponse(final String key,
final TenantConfigurationValue<?> repoConfValue) {
final MgmtSystemTenantConfigurationValue restConfValue = new MgmtSystemTenantConfigurationValue();

View File

@@ -35,27 +35,13 @@ public final class MgmtTargetFilterQueryMapper {
// Utility class
}
/**
* Create a response for target filter queries.
*
* @param filters
* list of targets
* @return the response
*/
public static List<MgmtTargetFilterQuery> toResponse(final List<TargetFilterQuery> filters) {
static List<MgmtTargetFilterQuery> toResponse(final List<TargetFilterQuery> filters) {
if (CollectionUtils.isEmpty(filters)) {
return Collections.emptyList();
}
return filters.stream().map(MgmtTargetFilterQueryMapper::toResponse).collect(Collectors.toList());
}
/**
* Create a response for target filter query.
*
* @param filter
* the target
* @return the response
*/
static MgmtTargetFilterQuery toResponse(final TargetFilterQuery filter) {
final MgmtTargetFilterQuery targetRest = new MgmtTargetFilterQuery();
targetRest.setFilterId(filter.getId());

View File

@@ -68,15 +68,7 @@ public final class MgmtTargetMapper {
.withRel(MgmtRestConstants.TARGET_V1_ACTIONS));
}
/**
* Add the poll status to a target response.
*
* @param target
* the target
* @param targetRest
* the response
*/
public static void addPollStatus(final Target target, final MgmtTarget targetRest) {
static void addPollStatus(final Target target, final MgmtTarget targetRest) {
final PollStatus pollStatus = target.getTargetInfo().getPollStatus();
if (pollStatus != null) {
final MgmtPollStatus pollStatusRest = new MgmtPollStatus();
@@ -89,14 +81,7 @@ public final class MgmtTargetMapper {
}
}
/**
* Create a response which includes links and pollstatus for all targets.
*
* @param targets
* the targets
* @return the response
*/
public static List<MgmtTarget> toResponseWithLinksAndPollStatus(final Collection<Target> targets) {
static List<MgmtTarget> toResponseWithLinksAndPollStatus(final Collection<Target> targets) {
if (targets == null) {
return Collections.emptyList();
}
@@ -109,14 +94,7 @@ public final class MgmtTargetMapper {
}).collect(Collectors.toList()));
}
/**
* Create a response for targets.
*
* @param targets
* list of targets
* @return the response
*/
public static List<MgmtTarget> toResponse(final Collection<Target> targets) {
static List<MgmtTarget> toResponse(final Collection<Target> targets) {
if (targets == null) {
return Collections.emptyList();
}
@@ -183,7 +161,7 @@ public final class MgmtTargetMapper {
.collect(Collectors.toList());
}
static TargetCreate fromRequest(final EntityFactory entityFactory, final MgmtTargetRequestBody targetRest) {
private static TargetCreate fromRequest(final EntityFactory entityFactory, final MgmtTargetRequestBody targetRest) {
return entityFactory.target().create().controllerId(targetRest.getControllerId()).name(targetRest.getName())
.description(targetRest.getDescription()).securityToken(targetRest.getSecurityToken())
.address(targetRest.getAddress());

View File

@@ -13,10 +13,6 @@ import org.eclipse.hawkbit.exception.SpServerError;
/**
* Thrown if too many status entries have been inserted.
*
*
*
*
*/
public final class ToManyAttributeEntriesException extends AbstractServerRtException {
/**

View File

@@ -51,7 +51,7 @@ public abstract class AbstractJpaNamedEntity extends AbstractJpaTenantAwareBaseE
* @param description
* of the {@link NamedEntity}
*/
public AbstractJpaNamedEntity(final String name, final String description) {
AbstractJpaNamedEntity(final String name, final String description) {
this.name = name;
this.description = description;
}

View File

@@ -41,7 +41,7 @@ public abstract class AbstractJpaNamedVersionedEntity extends AbstractJpaNamedEn
* of the entity
* @param description
*/
public AbstractJpaNamedVersionedEntity(final String name, final String version, final String description) {
AbstractJpaNamedVersionedEntity(final String name, final String version, final String description) {
super(name, description);
this.version = version;
}

View File

@@ -47,7 +47,7 @@ public abstract class AbstractJpaTenantAwareBaseEntity extends AbstractJpaBaseEn
* entities.
*/
@PrePersist
public void prePersist() {
void prePersist() {
// before persisting the entity check the current ID of the tenant by
// using the TenantAware
// service

View File

@@ -66,7 +66,7 @@ public class DistributionSetTypeElement implements Serializable {
* to <code>true</code> if the {@link SoftwareModuleType} if
* mandatory element in the {@link DistributionSet}.
*/
public DistributionSetTypeElement(final JpaDistributionSetType dsType, final JpaSoftwareModuleType smType,
DistributionSetTypeElement(final JpaDistributionSetType dsType, final JpaSoftwareModuleType smType,
final boolean mandatory) {
super();
key = new DistributionSetTypeElementCompositeKey(dsType, smType);
@@ -75,7 +75,7 @@ public class DistributionSetTypeElement implements Serializable {
this.mandatory = mandatory;
}
public DistributionSetTypeElement setMandatory(final boolean mandatory) {
DistributionSetTypeElement setMandatory(final boolean mandatory) {
this.mandatory = mandatory;
return this;
}

View File

@@ -117,22 +117,6 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
this.occurredAt = occurredAt;
}
/**
* Creates a new {@link ActionStatus} object.
*
* @param status
* the status for this action status
* @param occurredAt
* the occurred timestamp
* @param message
* the message which should be added to this action status
*/
public JpaActionStatus(final Status status, final Long occurredAt, final String message) {
this.status = status;
this.occurredAt = occurredAt;
addMessage(message);
}
/**
* JPA default constructor.
*/

View File

@@ -41,16 +41,6 @@ public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag,
@ManyToMany(mappedBy = "tags", targetEntity = JpaDistributionSet.class, fetch = FetchType.LAZY)
private List<DistributionSet> assignedToDistributionSet;
/**
* Public constructor.
*
* @param name
* of the {@link DistributionSetTag}
**/
public JpaDistributionSetTag(final String name) {
super(name, null, null);
}
/**
* Public constructor.
*

View File

@@ -56,19 +56,6 @@ public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity imple
// Default constructor for JPA.
}
/**
* Public constructor.
*
* @param name
* of the {@link TargetFilterQuery}.
* @param query
* of the {@link TargetFilterQuery}.
*/
public JpaTargetFilterQuery(final String name, final String query) {
this.name = name;
this.query = query;
}
/**
* Construct a Target filter query with auto assign distribution set
*

View File

@@ -55,16 +55,6 @@ public class JpaTargetTag extends JpaTag implements TargetTag, EventAwareEntity
super(name, description, colour);
}
/**
* Public constructor.
*
* @param name
* of the {@link TargetTag}
**/
public JpaTargetTag(final String name) {
super(name, null, null);
}
public JpaTargetTag() {
// Default constructor for JPA.
}

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.ui;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import java.util.Set;
@@ -156,13 +157,14 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
setContent(rootLayout);
final Resource resource = context
.getResource("classpath:/VAADIN/themes/" + UI.getCurrent().getTheme() + "/layouts/footer.html");
try {
final CustomLayout customLayout = new CustomLayout(resource.getInputStream());
try (InputStream resourceStream = resource.getInputStream()) {
final CustomLayout customLayout = new CustomLayout(resourceStream);
customLayout.setSizeUndefined();
contentVerticalLayout.addComponent(customLayout);
} catch (final IOException ex) {
LOG.error("Footer file is missing", ex);
LOG.error("Footer file cannot be loaded", ex);
}
final Navigator navigator = new Navigator(this, content);
navigator.addViewChangeListener(new ViewChangeListener() {
private static final long serialVersionUID = 1L;

View File

@@ -424,19 +424,11 @@ public class ArtifactDetailsLayout extends VerticalLayout {
/**
* Set title of artifact details header layout.
*/
public void setTitleOfLayoutHeader() {
private void setTitleOfLayoutHeader() {
titleOfArtifactDetails.setValue(HawkbitCommonUtil.getArtifactoryDetailsLabelId(""));
titleOfArtifactDetails.setContentMode(ContentMode.HTML);
}
/**
* Close artifact details layout.
*/
public void closeArtifactDetails() {
removeAllComponents();
setVisible(false);
}
@EventBusListenerMethod(scope = EventScope.UI)
void onEvent(final SoftwareModuleEvent softwareModuleEvent) {
if (BaseEntityEventType.SELECTED_ENTITY == softwareModuleEvent.getEventType()) {

View File

@@ -100,8 +100,6 @@ public class UploadLayout extends VerticalLayout {
private UploadConfirmationWindow currentUploadConfirmationwindow;
private VerticalLayout dropAreaLayout;
private final UI ui;
private HorizontalLayout fileUploadLayout;
@@ -309,7 +307,7 @@ public class UploadLayout extends VerticalLayout {
}
private VerticalLayout createDropAreaLayout() {
dropAreaLayout = new VerticalLayout();
final VerticalLayout dropAreaLayout = new VerticalLayout();
final Label dropHereLabel = new Label("Drop files to upload");
dropHereLabel.setWidth(null);
@@ -403,7 +401,7 @@ public class UploadLayout extends VerticalLayout {
}
Boolean validate(final DragAndDropEvent event) {
private Boolean validate(final DragAndDropEvent event) {
// check if drop is valid.If valid ,check if software module is
// selected.
if (!isFilesDropped(event)) {
@@ -446,7 +444,7 @@ public class UploadLayout extends VerticalLayout {
* the current selected sm module
* @return Boolean
*/
public Boolean checkIfFileIsDuplicate(final String name, final SoftwareModule selectedSoftwareModule) {
Boolean checkIfFileIsDuplicate(final String name, final SoftwareModule selectedSoftwareModule) {
Boolean isDuplicate = false;
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil
.getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
@@ -462,18 +460,18 @@ public class UploadLayout extends VerticalLayout {
return isDuplicate;
}
void decreaseNumberOfFileUploadsExpected() {
private void decreaseNumberOfFileUploadsExpected() {
artifactUploadState.getNumberOfFileUploadsExpected().decrementAndGet();
}
List<String> getDuplicateFileNamesList() {
private List<String> getDuplicateFileNamesList() {
return duplicateFileNamesList;
}
/**
* Update pending action count.
*/
void updateActionCount() {
private void updateActionCount() {
if (!artifactUploadState.getFileSelected().isEmpty()) {
processBtn.setCaption(SPUILabelDefinitions.PROCESS + "<div class='unread'>"
+ artifactUploadState.getFileSelected().size() + HTML_DIV);
@@ -482,7 +480,7 @@ public class UploadLayout extends VerticalLayout {
}
}
void displayDuplicateValidationMessage() {
private void displayDuplicateValidationMessage() {
// check if streaming of all dropped files are completed
if (artifactUploadState.getNumberOfFilesActuallyUpload().intValue() == artifactUploadState
.getNumberOfFileUploadsExpected().intValue()) {
@@ -505,18 +503,11 @@ public class UploadLayout extends VerticalLayout {
return message.toString();
}
/**
* Show the duplicated message.
*/
public void showDuplicateMessage() {
uiNotification.displayValidationError(getDuplicateFileValidationMessage());
}
void increaseNumberOfFileUploadsExpected() {
artifactUploadState.getNumberOfFileUploadsExpected().incrementAndGet();
}
void updateFileSize(final String name, final long size, final SoftwareModule selectedSoftwareModule) {
private void updateFileSize(final String name, final long size, final SoftwareModule selectedSoftwareModule) {
final String currentBaseSoftwareModuleKey = HawkbitCommonUtil
.getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion());
@@ -530,18 +521,18 @@ public class UploadLayout extends VerticalLayout {
}
}
void increaseNumberOfFilesActuallyUpload() {
private void increaseNumberOfFilesActuallyUpload() {
artifactUploadState.getNumberOfFilesActuallyUpload().incrementAndGet();
}
void increaseNumberOfFileUploadsFailed() {
private void increaseNumberOfFileUploadsFailed() {
artifactUploadState.getNumberOfFileUploadsFailed().incrementAndGet();
}
/**
* Enable process button once upload is completed.
*/
boolean enableProcessBtn() {
private boolean enableProcessBtn() {
if (artifactUploadState.getNumberOfFilesActuallyUpload().intValue() >= artifactUploadState
.getNumberOfFileUploadsExpected().intValue() && !getFileSelected().isEmpty()) {
processBtn.setEnabled(true);
@@ -652,13 +643,6 @@ public class UploadLayout extends VerticalLayout {
this.currentUploadConfirmationwindow = currentUploadConfirmationwindow;
}
/**
* @return
*/
VerticalLayout getDropAreaLayout() {
return dropAreaLayout;
}
private void onStartOfUpload() {
setUploadStatusButtonIconToInProgress();
if (artifactUploadState.isStatusPopupMinimized()) {
@@ -752,23 +736,10 @@ public class UploadLayout extends VerticalLayout {
}
}
/**
* set upload status and confirmation window.
*
* @param newWidth
* browser width
* @param newHeight
* browser height
*/
public void setUploadPopupSize(final float newWidth, final float newHeight) {
setConfirmationPopupHeightWidth(newWidth, newHeight);
setResultPopupHeightWidth(newWidth, newHeight);
}
/**
* @param selectedBaseSoftwareModule
*/
public void refreshArtifactDetailsLayout(final SoftwareModule selectedBaseSoftwareModule) {
void refreshArtifactDetailsLayout(final SoftwareModule selectedBaseSoftwareModule) {
eventBus.publish(this,
new SoftwareModuleEvent(SoftwareModuleEventType.ARTIFACTS_CHANGED, selectedBaseSoftwareModule));
}
@@ -799,7 +770,7 @@ public class UploadLayout extends VerticalLayout {
uploadStatusButton.setVisible(false);
}
void updateStatusButtonCount() {
private void updateStatusButtonCount() {
final int uploadsPending = artifactUploadState.getNumberOfFileUploadsExpected().get()
- artifactUploadState.getNumberOfFilesActuallyUpload().get();
final int uploadsFailed = artifactUploadState.getNumberOfFileUploadsFailed().get();
@@ -830,7 +801,7 @@ public class UploadLayout extends VerticalLayout {
updateStatusButtonCount();
}
protected void hideUploadStatusButton() {
private void hideUploadStatusButton() {
if (uploadStatusButton == null) {
return;
}

View File

@@ -1,20 +0,0 @@
/**
* 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.ui.common.confirmwindow.layout;
/**
* Confirm window action events.
*
*
*
*
*/
public enum ConfirmationWindowEvents {
DISCARD_DELETE_SOFTWARE_TYPE, DISCARD_ALL_DELETE_SOFTWARE_TYPE, DELETE_ALL_SOFWARE_TYPE, DISCARD_DELETE_DIST_TYPE, DISCARD_ALL_DELETE_DIST_TYPE, DELETE_ALL_DIST_TYPE, DISCARD_DELETE_SOFTWARE_MODULE, DISCARD_ALL_DELETE_SOFTWARE_MODULE, DELETE_ALL_SOFTWARE_MODULE, DISCARD_DELETE_DISTRIBUTION, DISCARD_ALL_DELETE_DISTRIBUTION, DELETE_ALL_DISTRIBUTION, DISCARD_DELETE_TARGET, DISCARD_ALL_DELETE_TARGET, DELETE_ALL_TARGET, SAVED_ASSIGNMENTS, DISCARD_ALL_ASSIGNMENTS, DISCARD_ASSIGNMENTS
}

View File

@@ -25,7 +25,6 @@ import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
import com.vaadin.server.FontAwesome;
@@ -48,8 +47,6 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
private final I18N i18n;
private final transient EventBus.UIEventBus eventBus;
private final SpPermissionChecker permissionChecker;
private T selectedBaseEntity;
@@ -75,7 +72,6 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
protected AbstractTableDetailsLayout(final I18N i18n, final UIEventBus eventBus,
final SpPermissionChecker permissionChecker, final ManagementUIState managementUIState) {
this.i18n = i18n;
this.eventBus = eventBus;
this.permissionChecker = permissionChecker;
this.managementUIState = managementUIState;
detailsLayout = getTabLayout();
@@ -91,10 +87,6 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
return permissionChecker;
}
protected EventBus.UIEventBus getEventBus() {
return eventBus;
}
protected I18N getI18n() {
return i18n;
}

View File

@@ -183,7 +183,7 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table impl
}
}
protected void applyMaxTableSettings() {
private void applyMaxTableSettings() {
setColumnProperties();
setValue(null);
setSelectable(false);
@@ -192,7 +192,7 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table impl
setColumnCollapsingAllowed(true);
}
protected void applyMinTableSettings() {
private void applyMinTableSettings() {
setDefault();
setColumnProperties();
selectRow();

View File

@@ -57,7 +57,7 @@ public class NotificationUnreadButton extends Button {
* i18n
*/
@Autowired
public NotificationUnreadButton(final I18N i18n) {
NotificationUnreadButton(final I18N i18n) {
this.i18n = i18n;
this.unreadNotifications = new ConcurrentHashMap<>();
setIcon(FontAwesome.BELL);

View File

@@ -1,29 +0,0 @@
/**
* 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.ui.decorators;
import com.vaadin.ui.HorizontalLayout;
/**
*
*
* Ui header layout decorater.
*/
@FunctionalInterface
public interface HeaderLayoutDecorator {
/**
* decorate the header
*
* @param layout
* the layout
* @return the decorated layout
*/
HorizontalLayout decorate(HorizontalLayout layout);
}

View File

@@ -1,46 +0,0 @@
/**
* 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.ui.decorators;
import com.vaadin.server.Resource;
import com.vaadin.ui.Button;
import com.vaadin.ui.themes.ValoTheme;
/**
*
* Large icon button created to show or hide button.
*
*
*
*
*
*/
public class SPUIButtonStyleLargeIconNoBorder implements SPUIButtonDecorator {
/**
* {@inheritDoc}
*/
@Override
public Button decorate(Button button, String style, boolean setStyle, Resource icon) {
button.addStyleName(ValoTheme.BUTTON_LARGE);
button.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
if (setStyle && style != null) {
button.addStyleName(style);
}
button.setWidthUndefined();
// Set icon
if (null != icon) {
button.setIcon(icon);
}
return button;
}
}

View File

@@ -1,40 +0,0 @@
/**
* 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.ui.decorators;
import com.vaadin.server.Resource;
import com.vaadin.ui.Button;
import com.vaadin.ui.themes.ValoTheme;
/**
* Style for button: Primary.
*/
public class SPUIButtonStylePrimarySmall implements SPUIButtonDecorator {
@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
button.addStyleName(ValoTheme.BUTTON_PRIMARY + " " + ValoTheme.BUTTON_SMALL);
// Set Style
if (null != style) {
if (setStyle) {
button.setStyleName(style);
} else {
button.addStyleName(style);
}
}
// Set icon
if (null != icon) {
button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
button.setIcon(icon);
}
return button;
}
}

View File

@@ -1,43 +0,0 @@
/**
* 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.ui.decorators;
import com.vaadin.server.Resource;
import com.vaadin.ui.Button;
import com.vaadin.ui.themes.ValoTheme;
/**
* Style for button: Small NoBorder Height and size UnDefined.
*
*/
public class SPUIButtonStyleSmallNoBorderUHS implements SPUIButtonDecorator {
@Override
public Button decorate(final Button button, final String style, final boolean setStyle, final Resource icon) {
button.addStyleName(ValoTheme.BUTTON_SMALL);
button.addStyleName(ValoTheme.BUTTON_BORDERLESS);
button.setHeightUndefined();
button.setSizeUndefined();
// Set Style
if (null != style) {
if (setStyle) {
button.setStyleName(style);
} else {
button.addStyleName(style);
}
}
// Set icon
if (null != icon) {
button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
button.setIcon(icon);
}
return button;
}
}

View File

@@ -1,68 +0,0 @@
/**
* 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.ui.decorators;
import com.vaadin.server.ThemeResource;
import com.vaadin.ui.Embedded;
/**
* Embedded with required style.
*
*
*
*/
public final class SPUIEmbedDecorator {
/**
* Private Constructor.
*/
private SPUIEmbedDecorator() {
}
/**
* Decorate.
*
* @param spUIEmbdValue
* as DTO
* @return Embedded as UI
*/
public static Embedded decorate(final SPUIEmbedValue spUIEmbdValue) {
final Embedded spUIEmbd = new Embedded();
spUIEmbd.setImmediate(spUIEmbdValue.isImmediate());
spUIEmbd.setType(spUIEmbdValue.getType());
if (null != spUIEmbdValue.getId()) {
spUIEmbd.setId(spUIEmbdValue.getId());
}
if (null != spUIEmbdValue.getData()) {
spUIEmbd.setData(spUIEmbdValue.getData());
}
if (null != spUIEmbdValue.getStyleName()) {
spUIEmbd.setStyleName(spUIEmbdValue.getStyleName());
}
if (null != spUIEmbdValue.getSource()) {
spUIEmbd.setSource(new ThemeResource(spUIEmbdValue.getSource()));
}
if (null != spUIEmbdValue.getMimeType()) {
spUIEmbd.setMimeType(spUIEmbdValue.getMimeType());
}
if (null != spUIEmbdValue.getDescription()) {
spUIEmbd.setDescription(spUIEmbdValue.getDescription());
}
return spUIEmbd;
}
}

View File

@@ -42,7 +42,7 @@ public abstract class CreateUpdateTypeLayout<E extends NamedEntity> extends Abst
protected TextField typeKey;
public static final String TYPE_NAME_DYNAMIC_STYLE = "new-tag-name";
private static final String TYPE_NAME_DYNAMIC_STYLE = "new-tag-name";
private static final String TYPE_DESC_DYNAMIC_STYLE = "new-tag-desc";
public CreateUpdateTypeLayout(final I18N i18n, final TagManagement tagManagement, final EntityFactory entityFactory,
@@ -94,7 +94,7 @@ public abstract class CreateUpdateTypeLayout<E extends NamedEntity> extends Abst
* @param tagDesc
* @param taregtTagColor
*/
protected void createDynamicStyleForComponents(final TextField tagName, final TextField typeKey,
private void createDynamicStyleForComponents(final TextField tagName, final TextField typeKey,
final TextArea typeDesc, final String typeTagColor) {
tagName.removeStyleName(SPUIDefinitions.TYPE_NAME);

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.ui.login;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.hawkbit.ui.DefaultHawkbitUI;
import org.eclipse.hawkbit.ui.HawkbitUI;
@@ -70,12 +71,13 @@ public class HawkbitLoginUI extends DefaultHawkbitUI {
rootLayout.setExpandRatio(content, 2.0F);
final Resource resource = context
.getResource("classpath:/VAADIN/themes/" + UI.getCurrent().getTheme() + "/layouts/footer.html");
try {
final CustomLayout customLayout = new CustomLayout(resource.getInputStream());
try (InputStream resourceStream = resource.getInputStream()) {
final CustomLayout customLayout = new CustomLayout(resourceStream);
customLayout.setSizeUndefined();
rootLayout.addComponent(customLayout);
} catch (final IOException ex) {
LOG.error("Footer file is missing", ex);
LOG.error("Footer file cannot be loaded", ex);
}
setContent(rootLayout);

View File

@@ -24,14 +24,7 @@ public final class DeleteActionsLayoutHelper {
}
/**
* Checks if component is a target tag.
*
* @param source
* Component dropped
* @return true if it component is target tag
*/
public static boolean isTargetTag(final Component source) {
static boolean isTargetTag(final Component source) {
if (source instanceof DragAndDropWrapper) {
final String wrapperData = ((DragAndDropWrapper) source).getData().toString();
final String id = wrapperData.replace(SPUIDefinitions.TARGET_TAG_BUTTON, "");
@@ -42,14 +35,7 @@ public final class DeleteActionsLayoutHelper {
return false;
}
/**
* Checks if component is distribution tag.
*
* @param source
* component dropped
* @return true if it component is distribution tag
*/
public static boolean isDistributionTag(final Component source) {
static boolean isDistributionTag(final Component source) {
if (source instanceof DragAndDropWrapper) {
final String wrapperData = ((DragAndDropWrapper) source).getData().toString();
final String id = wrapperData.replace(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON, "");
@@ -58,62 +44,27 @@ public final class DeleteActionsLayoutHelper {
return false;
}
/**
* Extract the ds tag id by the drag and drop component
*
* @param source
* the source
* @return the ds tag id
*/
public static Long getDistributionTagId(final DragAndDropWrapper source) {
static Long getDistributionTagId(final DragAndDropWrapper source) {
final String wrapperData = source.getData().toString();
final String id = wrapperData.replace(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON, "");
return Long.valueOf(id.trim());
}
/**
* Extract the target tag id by the drag and drop component
*
* @param source
* the source
* @return the target tag id
*/
public static Long getTargetTagId(final DragAndDropWrapper source) {
static Long getTargetTagId(final DragAndDropWrapper source) {
final String wrapperData = source.getData().toString();
final String id = wrapperData.replace(SPUIDefinitions.TARGET_TAG_BUTTON, "");
return Long.valueOf(id.trim());
}
/**
* Checks if component is target table.
*
* @param source
* component dropped
* @return true if it component is target table
*/
public static boolean isTargetTable(final Component source) {
static boolean isTargetTable(final Component source) {
return UIComponentIdProvider.TARGET_TABLE_ID.equalsIgnoreCase(source.getId());
}
/**
* Checks id component is distribution table.
*
* @param source
* component dropped
* @return true if it component is distribution table
*/
public static boolean isDistributionTable(final Component source) {
static boolean isDistributionTable(final Component source) {
return UIComponentIdProvider.DIST_TABLE_ID.equalsIgnoreCase(source.getId());
}
/**
* Check if dropped component can be deleted.
*
* @param source
* component dropped
* @return true if component can be deleted
*/
public static Boolean isComponentDeletable(final Component source) {
static Boolean isComponentDeletable(final Component source) {
return isTargetTable(source) || isDistributionTable(source) || isTargetTag(source) || isDistributionTag(source);
}

View File

@@ -256,23 +256,6 @@ public class ManagementUIState implements ManagmentEntityState<DistributionSetId
this.targetsCountAll.set(targetsCountAll);
}
/**
* increments the targets all counter.
*/
public void incrementTargetsCountAll() {
targetsCountAll.incrementAndGet();
}
/**
* decrement the targets all counter.
*/
public void decrementTargetsCountAll() {
final long decrementAndGet = targetsCountAll.decrementAndGet();
if (decrementAndGet < 0) {
targetsCountAll.set(0);
}
}
public boolean isDsTableMaximized() {
return dsTableMaximized;
}

View File

@@ -1,142 +0,0 @@
/**
* 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.ui.management.state;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.VaadinSessionScope;
/**
* Holds the filter parameters for target table.
*
*
*/
@SpringComponent
@VaadinSessionScope
public class TargetFilterParameters implements Serializable {
private static final long serialVersionUID = 3929484222793744883L;
private String searchText;
private final List<TargetUpdateStatus> status = new ArrayList<>();
private List<String> targetTags = new ArrayList<>();
private Long distributionSetId;
private Long pinnedDistId;
/**
* Get search Text.
*
* @return string as search text
*/
public String getSearchText() {
return searchText;
}
/**
* Set Search Text.
*
* @param searchText
* as string
*/
public void setSearchText(final String searchText) {
this.searchText = searchText;
}
/**
* Get update status.
*
* @return TargetUpdateStatus
*/
public List<TargetUpdateStatus> getStatus() {
return status;
}
/**
* Adds Target update status.
*
* @param status
* as Target update
*/
public void addStatus(final TargetUpdateStatus status) {
this.status.add(status);
}
/**
* Remoces Target update status.
*
* @param status
* as Target update
*/
public void removeStatus(final TargetUpdateStatus status) {
this.status.remove(status);
}
/**
* Get Target Tags.
*
* @return List of Tags
*/
public List<String> getTargetTags() {
return targetTags;
}
/**
* Set Target Tags.
*
* @param targetTags
* as tags
*/
public void setTargetTags(final List<String> targetTags) {
this.targetTags = targetTags;
}
/**
* Get Distribution ID.
*
* @return Dist ID
*/
public Long getDistributionSetId() {
return distributionSetId;
}
/**
* Set distribution ID.
*
* @param distributionSetId
* as ID
*/
public void setDistributionSetId(final Long distributionSetId) {
this.distributionSetId = distributionSetId;
}
/**
* @return Returns the pinnedDistId.
*/
public Long getPinnedDistId() {
return pinnedDistId;
}
/**
* @param pinnedDistId
* The pinned distribution set Id to set.
*/
public void setPinnedDistId(final Long pinnedDistId) {
this.pinnedDistId = pinnedDistId;
}
}

View File

@@ -84,7 +84,7 @@ public class BulkUploadHandler extends CustomComponent
private final transient DeploymentManagement deploymentManagement;
private final transient DistributionSetManagement distributionSetManagement;
protected File tempFile;
private File tempFile;
private Upload upload;
private final ProgressBar progressBar;
@@ -101,7 +101,7 @@ public class BulkUploadHandler extends CustomComponent
private transient EntityFactory entityFactory;
private final UI uiInstance;
BulkUploadHandler(final TargetBulkUpdateWindowLayout targetBulkUpdateWindowLayout,
public BulkUploadHandler(final TargetBulkUpdateWindowLayout targetBulkUpdateWindowLayout,
final TargetManagement targetManagement, final ManagementUIState managementUIState,
final DeploymentManagement deploymentManagement, final I18N i18n, final UI uiInstance) {
this.uiInstance = uiInstance;
@@ -121,10 +121,7 @@ public class BulkUploadHandler extends CustomComponent
entityFactory = SpringContextHelper.getBean(EntityFactory.class);
}
/**
* Intialize layout.
*/
public void buildLayout() {
void buildLayout() {
final HorizontalLayout horizontalLayout = new HorizontalLayout();
upload = new Upload();
upload.setEnabled(false);
@@ -162,21 +159,11 @@ public class BulkUploadHandler extends CustomComponent
@Override
public void uploadSucceeded(final SucceededEvent event) {
executor.execute(new UploadAsync(event));
executor.execute(new UploadAsync());
}
class UploadAsync implements Runnable {
final SucceededEvent event;
/**
*
* @param event
*/
public UploadAsync(final SucceededEvent event) {
this.event = event;
}
@Override
public void run() {
if (tempFile == null) {

View File

@@ -16,7 +16,7 @@ import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.event.TargetFilterEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIButtonDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventBus.UIEventBus;
@@ -70,13 +70,13 @@ public class FilterByStatusLayout extends VerticalLayout implements Button.Click
/**
* Initialize the Status Layout Component.
*/
public void init() {
void init() {
getFilterTargetsStatusLayout();
restorePreviousState();
eventBus.subscribe(this);
}
public void getFilterTargetsStatusLayout() {
private void getFilterTargetsStatusLayout() {
getTargetFilterStatuses();
@@ -150,22 +150,22 @@ public class FilterByStatusLayout extends VerticalLayout implements Button.Click
private void getTargetFilterStatuses() {
unknown = SPUIComponentProvider.getButton(UIComponentIdProvider.UNKNOWN_STATUS_ICON,
TargetUpdateStatus.UNKNOWN.toString(), i18n.get("tooltip.status.unknown"),
SPUIButtonDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
SPUIDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
inSync = SPUIComponentProvider.getButton(UIComponentIdProvider.INSYNCH_STATUS_ICON,
TargetUpdateStatus.IN_SYNC.toString(), i18n.get("tooltip.status.insync"),
SPUIButtonDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
SPUIDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
pending = SPUIComponentProvider.getButton(UIComponentIdProvider.PENDING_STATUS_ICON,
TargetUpdateStatus.PENDING.toString(), i18n.get("tooltip.status.pending"),
SPUIButtonDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
SPUIDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
error = SPUIComponentProvider.getButton(UIComponentIdProvider.ERROR_STATUS_ICON,
TargetUpdateStatus.ERROR.toString(), i18n.get("tooltip.status.error"),
SPUIButtonDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
SPUIDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
registered = SPUIComponentProvider.getButton(UIComponentIdProvider.REGISTERED_STATUS_ICON,
TargetUpdateStatus.REGISTERED.toString(), i18n.get("tooltip.status.registered"),
SPUIButtonDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
SPUIDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
overdue = SPUIComponentProvider.getButton(UIComponentIdProvider.OVERDUE_STATUS_ICON, OVERDUE_CAPTION,
i18n.get("tooltip.status.overdue"), SPUIButtonDefinitions.SP_BUTTON_STATUS_STYLE, false,
FontAwesome.SQUARE, SPUIButtonStyleSmall.class);
i18n.get("tooltip.status.overdue"), SPUIDefinitions.SP_BUTTON_STATUS_STYLE, false, FontAwesome.SQUARE,
SPUIButtonStyleSmall.class);
applyStatusBtnStyle();
unknown.setData("filterStatusOne");
inSync.setData("filterStatusTwo");

View File

@@ -204,16 +204,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
}
}
/**
* Get the window.
*
* @param rolloutId
* the rollout id
* @param copy
* whether the rollout should be copied
* @return the window
*/
public CommonDialogWindow getWindow(final Long rolloutId, final boolean copy) {
CommonDialogWindow getWindow(final Long rolloutId, final boolean copy) {
resetComponents();
window = createWindow();
populateData(rolloutId, copy);
@@ -239,7 +230,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
/**
* Reset the field values.
*/
public void resetComponents() {
private void resetComponents() {
defineGroupsLayout.resetComponents();
editRolloutEnabled = false;
rolloutName.clear();
@@ -378,7 +369,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
}
private void displayValidationStatus(DefineGroupsLayout.ValidationStatus status) {
private void displayValidationStatus(final DefineGroupsLayout.ValidationStatus status) {
if (status == DefineGroupsLayout.ValidationStatus.LOADING) {
groupsLegendLayout.displayLoading();
} else {
@@ -387,17 +378,17 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
}
private TabSheet createGroupDefinitionTabs() {
TabSheet tabSheet = new TabSheet();
final TabSheet tabSheet = new TabSheet();
tabSheet.setId(UIComponentIdProvider.ROLLOUT_GROUPS);
tabSheet.setWidth(850, Unit.PIXELS);
tabSheet.setHeight(300, Unit.PIXELS);
tabSheet.setStyleName(SPUIStyleDefinitions.ROLLOUT_GROUPS);
TabSheet.Tab simpleTab = tabSheet.addTab(createSimpleGroupDefinitionTab(),
final TabSheet.Tab simpleTab = tabSheet.addTab(createSimpleGroupDefinitionTab(),
i18n.get("caption.rollout.tabs.simple"));
simpleTab.setId(UIComponentIdProvider.ROLLOUT_SIMPLE_TAB);
TabSheet.Tab advancedTab = tabSheet.addTab(defineGroupsLayout, i18n.get("caption.rollout.tabs.advanced"));
final TabSheet.Tab advancedTab = tabSheet.addTab(defineGroupsLayout, i18n.get("caption.rollout.tabs.advanced"));
advancedTab.setId(UIComponentIdProvider.ROLLOUT_ADVANCED_TAB);
tabSheet.addSelectedTabChangeListener(event -> validateGroups());
@@ -418,7 +409,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
}
private GridLayout createSimpleGroupDefinitionTab() {
GridLayout layout = new GridLayout();
final GridLayout layout = new GridLayout();
layout.setSpacing(true);
layout.setColumns(3);
layout.setRows(4);
@@ -493,7 +484,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
return;
}
if (isGroupsDefinition()) {
List<RolloutGroupCreate> savedRolloutGroups = defineGroupsLayout.getSavedRolloutGroups();
final List<RolloutGroupCreate> savedRolloutGroups = defineGroupsLayout.getSavedRolloutGroups();
if (!defineGroupsLayout.isValid() || savedRolloutGroups == null || savedRolloutGroups.isEmpty()) {
noOfGroups.clear();
} else {
@@ -516,7 +507,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
groupsPieChart.setChartState(null, null);
return;
}
List<Long> targetsPerGroup = validation.getTargetsPerGroup();
final List<Long> targetsPerGroup = validation.getTargetsPerGroup();
if (validation.getTotalTargets() == 0L || targetsPerGroup.isEmpty()) {
groupsPieChart.setChartState(null, null);
} else {
@@ -529,8 +520,8 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
}
private void updateGroupsChart(final List<RolloutGroup> savedGroups, long totalTargetsCount) {
List<Long> targetsPerGroup = savedGroups.stream().map(group -> (long) group.getTotalTargets())
private void updateGroupsChart(final List<RolloutGroup> savedGroups, final long totalTargetsCount) {
final List<Long> targetsPerGroup = savedGroups.stream().map(group -> (long) group.getTotalTargets())
.collect(Collectors.toList());
groupsPieChart.setChartState(targetsPerGroup, totalTargetsCount);
@@ -545,8 +536,8 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
final List<Long> groups = new ArrayList<>(amountOfGroups);
long leftTargets = totalTargetsCount;
for (int i = 0; i < amountOfGroups; i++) {
float percentage = 1.0F / (amountOfGroups - i);
long targetsInGroup = Math.round(percentage * (double) leftTargets);
final float percentage = 1.0F / (amountOfGroups - i);
final long targetsInGroup = Math.round(percentage * (double) leftTargets);
leftTargets -= targetsInGroup;
groups.add(targetsInGroup);
}
@@ -611,7 +602,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
final DistributionSetIdName distributionSetIdName = (DistributionSetIdName) distributionSet.getValue();
RolloutUpdate rolloutUpdate = entityFactory.rollout().update(rollout.getId()).name(rolloutName.getValue())
final RolloutUpdate rolloutUpdate = entityFactory.rollout().update(rollout.getId()).name(rolloutName.getValue())
.description(description.getValue()).set(distributionSetIdName.getId()).actionType(getActionType())
.forcedTime(getForcedTimeStamp());
@@ -630,8 +621,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
private boolean duplicateCheckForEdit() {
final String rolloutNameVal = getRolloutName();
if (!rollout.getName().equals(rolloutNameVal)
&& rolloutManagement.findRolloutByName(rolloutNameVal) != null) {
if (!rollout.getName().equals(rolloutNameVal) && rolloutManagement.findRolloutByName(rolloutNameVal) != null) {
uiNotification.displayValidationError(i18n.get("message.rollout.duplicate.check", rolloutNameVal));
return false;
}
@@ -690,7 +680,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
if (isNumberOfGroups()) {
return rolloutManagement.createRollout(rolloutCreate, amountGroup, conditions);
} else if (isGroupsDefinition()) {
List<RolloutGroupCreate> groups = defineGroupsLayout.getSavedRolloutGroups();
final List<RolloutGroupCreate> groups = defineGroupsLayout.getSavedRolloutGroups();
return rolloutManagement.createRollout(rolloutCreate, groups, conditions);
}
@@ -719,8 +709,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
private boolean duplicateCheck() {
if (rolloutManagement.findRolloutByName(getRolloutName()) != null) {
uiNotification.displayValidationError(
i18n.get("message.rollout.duplicate.check", getRolloutName()));
uiNotification.displayValidationError(i18n.get("message.rollout.duplicate.check", getRolloutName()));
return false;
}
return true;

View File

@@ -47,7 +47,7 @@ public class AutoStartOptionGroupLayout extends HorizontalLayout {
* @param i18n
* the internationalization helper
*/
public AutoStartOptionGroupLayout(final I18N i18n) {
AutoStartOptionGroupLayout(final I18N i18n) {
this.i18n = i18n;
createOptionGroup();
@@ -138,18 +138,14 @@ public class AutoStartOptionGroupLayout extends HorizontalLayout {
addComponent(startAtDateField);
}
/**
* To Set Default option for save.
*/
public void selectDefaultOption() {
void selectDefaultOption() {
autoStartOptionGroup.select(AutoStartOption.MANUAL);
}
/**
* Rollout start options
*/
public enum AutoStartOption {
enum AutoStartOption {
MANUAL, AUTO_START, SCHEDULED;
}

View File

@@ -36,7 +36,7 @@ public class RolloutGroupTargetsCountLabelMessage extends Label {
private final I18N i18n;
public RolloutGroupTargetsCountLabelMessage(final RolloutUIState rolloutUIState,
RolloutGroupTargetsCountLabelMessage(final RolloutUIState rolloutUIState,
final RolloutGroupTargetsListGrid rolloutGroupTargetsListGrid, final I18N i18n, final UIEventBus eventBus) {
this.rolloutUIState = rolloutUIState;
this.rolloutGroupTargetsListGrid = rolloutGroupTargetsListGrid;
@@ -53,16 +53,12 @@ public class RolloutGroupTargetsCountLabelMessage extends Label {
* @param event
*/
@EventBusListenerMethod(scope = EventScope.UI)
public void onEvent(final RolloutEvent event) {
void onEvent(final RolloutEvent event) {
if (event == RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS_COUNT) {
displayRolloutGroupTargetMessage();
}
}
/**
*
*/
private void applyStyle() {
/* Create label for Targets count message displaying below the table */
addStyleName(SPUILabelDefinitions.SP_LABEL_MESSAGE_STYLE);

View File

@@ -42,9 +42,9 @@ public class DefaultDistributionSetTypeLayout extends BaseConfigurationView {
private TenantMetaData tenantMetaData;
final ComboBox combobox;
private final ComboBox combobox;
final Label changeIcon;
private final Label changeIcon;
DefaultDistributionSetTypeLayout(final SystemManagement systemManagement,
final DistributionSetManagement distributionSetManagement, final I18N i18n,
@@ -131,7 +131,7 @@ public class DefaultDistributionSetTypeLayout extends BaseConfigurationView {
/**
* Method that is called when combobox event is performed.
*/
public void selectDistributionSetValue() {
private void selectDistributionSetValue() {
selectedDefaultDisSetType = (Long) combobox.getValue();
if (!selectedDefaultDisSetType.equals(currentDefaultDisSetType)) {
changeIcon.setVisible(true);

View File

@@ -22,8 +22,6 @@ public final class HawkbitTheme {
public static final String LOGIN_UI_PATH = "/login";
public static final String HAWKBIT_UI_PATH = "";
/**
* private constructor, utility class.
*/

View File

@@ -42,10 +42,7 @@ import com.vaadin.ui.Table;
*/
public final class HawkbitCommonUtil {
public static final String SP_STRING_PIPE = " | ";
/**
* Html span.
*/
public static final String SPAN_CLOSE = "</span>";
public static final String HTML_LI_CLOSE_TAG = "</li>";
public static final String HTML_LI_OPEN_TAG = "<li>";
public static final String HTML_UL_CLOSE_TAG = "</ul>";
@@ -217,14 +214,7 @@ public final class HawkbitCommonUtil {
return trimAndNullIfEmpty(orgText) == null ? SPUIDefinitions.SPACE : orgText;
}
/**
* Find required extra width of software module.
*
* @param newBrowserWidth
* new browser width
* @return float width of software module table
*/
public static float findRequiredSwModuleExtraWidth(final float newBrowserWidth) {
private static float findRequiredSwModuleExtraWidth(final float newBrowserWidth) {
return newBrowserWidth > SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_WIDTH
? (newBrowserWidth - SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_WIDTH) : 0;
}
@@ -520,52 +510,13 @@ public final class HawkbitCommonUtil {
}
}
/**
* Set status progress bar value.
*
* @param bar
* DistributionBar
* @param statusName
* status name
* @param count
* target counts in a status
* @param index
* bar part index
*/
public static void setBarPartSize(final DistributionBar bar, final String statusName, final int count,
private static void setBarPartSize(final DistributionBar bar, final String statusName, final int count,
final int index) {
bar.setPartSize(index, count);
bar.setPartTooltip(index, statusName);
bar.setPartStyleName(index, "status-bar-part-" + statusName);
}
/**
* Initialize status progress bar with values and number of parts on load.
*
* @param bar
* DistributionBar
* @param item
* row of a table
*/
public static void initialiseProgressBar(final DistributionBar bar, final Item item) {
final Long notStartedTargetsCount = getStatusCount(SPUILabelDefinitions.VAR_COUNT_TARGETS_NOT_STARTED, item);
final Long runningTargetsCount = getStatusCount(SPUILabelDefinitions.VAR_COUNT_TARGETS_RUNNING, item);
final Long scheduledTargetsCount = getStatusCount(SPUILabelDefinitions.VAR_COUNT_TARGETS_SCHEDULED, item);
final Long errorTargetsCount = getStatusCount(SPUILabelDefinitions.VAR_COUNT_TARGETS_ERROR, item);
final Long finishedTargetsCount = getStatusCount(SPUILabelDefinitions.VAR_COUNT_TARGETS_FINISHED, item);
final Long cancelledTargetsCount = getStatusCount(SPUILabelDefinitions.VAR_COUNT_TARGETS_CANCELLED, item);
if (isNoTargets(errorTargetsCount, notStartedTargetsCount, runningTargetsCount, scheduledTargetsCount,
finishedTargetsCount, cancelledTargetsCount)) {
HawkbitCommonUtil.setBarPartSize(bar, TotalTargetCountStatus.Status.SCHEDULED.toString().toLowerCase(), 0,
0);
HawkbitCommonUtil.setBarPartSize(bar, TotalTargetCountStatus.Status.FINISHED.toString().toLowerCase(), 0,
1);
} else {
bar.setNumberOfParts(6);
setProgressBarDetails(bar, item);
}
}
/**
* Formats the finished percentage of a rollout group into a string with one
* digit after comma.

View File

@@ -1,49 +0,0 @@
/**
* 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.ui.utils;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicLong;
/**
* Implementation of {@link ThreadFactory} that sets thread names according to
* given name format. All threads are created by
* {@link Executors#defaultThreadFactory() #newThread(Runnable)}.
*
*
*/
public final class NamingThreadFactory implements ThreadFactory {
static final String SP_PREFIX = "SP-";
private final String nameFormat;
private final AtomicLong counter = new AtomicLong();
/**
* Creates a new {@link NamingThreadFactory}.
*
* @param nameFormat
* a {@link String#format(String, Object...)}-compatible format
* String, to which a unique integer (0, 1, etc.) will be
* supplied as the single parameter. This integer will be
* assigned sequentially. For example, "rpc-pool-%d" will
* generate thread names like "rpc-pool-0", "rpc-pool-1",
* "rpc-pool-2", etc.
*/
public NamingThreadFactory(final String nameFormat) {
this.nameFormat = SP_PREFIX + nameFormat;
}
@Override
public Thread newThread(final Runnable r) {
final Thread thread = Executors.defaultThreadFactory().newThread(r);
thread.setName(String.format(nameFormat, counter.getAndIncrement()));
return thread;
}
}

View File

@@ -42,7 +42,7 @@ public class NotificationMessage extends Notification {
* @param autoClose
* flag to indicate enable close option
*/
public void showNotification(final String styleName, final String caption, final String description,
void showNotification(final String styleName, final String caption, final String description,
final Boolean autoClose) {
decorate(styleName, caption, description, autoClose);
this.show(Page.getCurrent());

View File

@@ -1,72 +0,0 @@
/**
* 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.ui.utils;
/**
* RepositoryConstants required for Button.
*
*
*
*
*
*/
public final class SPUIButtonDefinitions {
/**
* BUTTON- STATUS.
*/
public static final String SP_BUTTON_STATUS_STYLE = "targetStatusBtn";
/**
* MESSAGE - POPUP-SHOW.
*/
public static final String SP_MESSAGE_HINT_POPUP_SHOW_STYLE = "message-hint-popup" + " "
+ "message-hint-popup-show";
/**
* Button Caption length.
*/
public static final int BUTTON_CAPTION_LENGTH = 12;
/**
* Unknown button description.
*/
public static final String UNKNOWN_BUTTON = "Unknown";
/**
* Registered button description.
*/
public static final String REGISTERED_BUTTON = "Registered";
/**
* Pending button description.
*/
public static final String PENDING_BUTTON = "Pending";
/**
* Error button description.
*/
public static final String ERROR_BUTTON = "Error";
/**
* In sync button description.
*/
public static final String IN_SYNCH_BUTTON = "In-sync";
/**
* Get lighter shade.
*/
public static final int CODE_VALUE = 50;
/**
* Edit Target Tag Style.
*/
public static final String TARGET_TAG_EDIT_STYLE = "edit-target-tag-icon";
/**
* Private Constructor.
*/
private SPUIButtonDefinitions() {
}
}

View File

@@ -338,16 +338,12 @@ public final class SPUIDefinitions {
/**
* Space.
*/
public static final String SPACE = "&nbsp;";
static final String SPACE = "&nbsp;";
/**
* Distribution tag button id prefix.
*/
public static final String SOFTWARE_MODULE_TAG_ID_PREFIXS = "swmodule.type.";
/**
* Distribution tag button id prefix.
*/
public static final String DISTRIBUTION_TYPE_ID_PREFIXS = "dist-type-";
/**
* DistributionSet Type tag button id prefix.
@@ -387,15 +383,15 @@ public final class SPUIDefinitions {
* automatically and also horizontal scroll bars get displayed. Used for
* Responsive UI.
*/
public static final int REQ_MIN_UPLOAD_BROWSER_WIDTH = 1250;
static final int REQ_MIN_UPLOAD_BROWSER_WIDTH = 1250;
public static final int MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH = 1000;
public static final int MIN_UPLOAD_CONFIRMATION_POPUP_HEIGHT = 310;
public static final int MAX_UPLOAD_CONFIRMATION_POPUP_WIDTH = 1050;
static final int MAX_UPLOAD_CONFIRMATION_POPUP_WIDTH = 1050;
public static final int MAX_UPLOAD_CONFIRMATION_POPUP_HEIGHT = 360;
static final int MAX_UPLOAD_CONFIRMATION_POPUP_HEIGHT = 360;
/** Artifact upload related entries - end. **/
@@ -502,6 +498,11 @@ public final class SPUIDefinitions {
*/
public static final String ROLLOUT_LIST_HEADER_CAPTION = "Rollouts";
/**
* BUTTON- STATUS.
*/
public static final String SP_BUTTON_STATUS_STYLE = "targetStatusBtn";
/**
* /** Constructor.
*/

View File

@@ -20,10 +20,6 @@ import com.vaadin.ui.themes.ValoTheme;
*/
public final class SPUILabelDefinitions {
/**
* Label - Message hint.
*/
public static final String SP_LABEL_MESSAGE_HINT = "Label-message-hint";
/**
* Style - Message.
*/

View File

@@ -11,16 +11,8 @@ package org.eclipse.hawkbit.ui.utils;
/**
* RepositoryConstants required for Style.
*
*
*
*
*
*/
public final class SPUIStyleDefinitions {
/**
* TABLE- HORI.
*/
public static final String SP_HORIZONTAL_TABLE_STYLE = "table-horizontal-layout";
/**
* Tag button wrapper style.
*/
@@ -33,36 +25,11 @@ public final class SPUIStyleDefinitions {
public static final String SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT = "v-textfield-error";
/**
* STYLE to highlight wrong data combo box field.
*/
public static final String SP_COMBOFIELD_ERROR = "combobox-error";
/**
* Style for control buttons in aciton history.
*/
public static final String SP_ACTION_HIS_CTRL_BTN = "action-history-ctl-buttons";
/**
* Style for accordion tab button.
*/
public static final String SP_ACCORDION_TAB_BTN = "accordion-tab-button-style";
/**
* large table style.
*/
public static final String SP_LARGE_TABLE_STYLE = "sp-table-large";
/**
* small table style.
*/
public static final String SP_SMALL_TABLE_STYLE = "sp-table-small";
/**
* Drag highligh layout style.
*/
public static final String DRAG_HIGHLIGHT_LAYOUT = "drag-hightlight-layout";
/**
* Confirm box question label style.
*/
@@ -73,24 +40,6 @@ public final class SPUIStyleDefinitions {
*/
public static final String CONFIRMBOX_WINDOW_SYLE = "confirmbox-window-style";
/**
* Distribution detail layout style.
*/
public static final String DIST_DETAIL_MODULE_TABLE = "dist-details-module-table";
/**
* Artifact upload - software module table layout.
*/
public static final String UPLOAD_SW_MODULE_TABLE_LAYOUT = "swModule-table-layout";
/**
* hide tags layout style.
*/
public static final String SP_HIDE_TYPE = "hide-type";
/**
* style for show type button.
*/
public static final String SP_SHOW_TYPE_ICON_STYLE = "show-type-icon";
/**
* Error label style.
*/
@@ -139,31 +88,16 @@ public final class SPUIStyleDefinitions {
*/
public static final String DS_METADATA_ICON = "ds-metadata-icon";
/**
* Target table style.
*/
public static final String TARGET_TABLE_STYLE = "target-table";
/**
* Details layout style.
*/
public static final String DETAILS_LAYOUT_STYLE = "details-tab";
/**
* Style for table panel to set short cut keys on the table.
*/
public static final String SHORT_CUT_KEY_TABLE_PANEL = "table-panel";
/**
* Confirmation popup - discard style.
*/
public static final String REDICON = "redicon";
/**
* Deployment view - message label style.
*/
public static final String COUNT_MSG_BOX_SHOW = "count-msg-box";
/**
* Action button style- footer buttons.
*/

View File

@@ -10,22 +10,8 @@ package org.eclipse.hawkbit.ui.utils;
/**
* RepositoryConstants required for Target.
*
*
*
*
*
*/
public final class SPUITargetDefinitions {
/**
* Target Table Style.
*/
public static final String TARGET_STYLE = "target-table";
/**
* Assignment tab column content size.
*/
public static final int ACCORDION_TAB_TARGET_NAME_LENGTH = 25;
/**
* Distribution name length .

View File

@@ -31,10 +31,6 @@ public final class SpringContextHelper {
SpringContextHelper.context = context;
}
public static ApplicationContext getContext() {
return context;
}
/**
* method to return a certain bean by its name.
*

View File

@@ -817,16 +817,6 @@ public final class UIComponentIdProvider {
*/
public static final String ROLLOUT_ERROR_THRESOLD_OPTION_ID = "rollout.error.thresold.option.id";
/**
* Rollout groups options id.
*/
public static final String ROLLOUT_GROUPS_OPTION_ID = "rollout.groups.option.id";
/**
* Rollout groups definition button
*/
public static final String ROLLOUT_GROUPS_DEF_BUTTON_ID = "rollout.groups.definition.button.id";
/**
* Rollout target filter query value text area id.
*/
@@ -904,16 +894,6 @@ public final class UIComponentIdProvider {
*/
public static final String METADATA_VALUE_ID = "metadata.value.id";
/**
* Metadata save id.
*/
public static final String METADTA_SAVE_ICON_ID = "metadata.save.icon.id";
/**
* Metadata discard id.
*/
public static final String METADTA_DISCARD_ICON_ID = "metadata.discard.icon.id";
/**
* Metadata add icon id.
*/

View File

@@ -1,73 +0,0 @@
/**
* 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.ui.utils;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.concurrent.ThreadFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.context.annotation.Description;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
@Features("Unit Tests - Management UI")
@Stories("Threads with NamingThreadFactory")
@RunWith(MockitoJUnitRunner.class)
public class NamingThreadFactoryTest {
@Mock
private final Runnable runnableMock = mock(Runnable.class);
@Test
@Description("Correct name of threads when created through NamingThreadFactory.")
public void setsNameForThreads() {
final String knownName = "knownName";
final ThreadFactory threadFactory = new NamingThreadFactory(knownName);
final Thread newThread1 = threadFactory.newThread(runnableMock);
final Thread newThread2 = threadFactory.newThread(runnableMock);
assertThat(newThread1.getName()).as("Name of the thread").isEqualTo(NamingThreadFactory.SP_PREFIX + knownName);
assertThat(newThread2.getName()).as("Name of the thread").isEqualTo(NamingThreadFactory.SP_PREFIX + knownName);
}
@Test
@Description("Correct name of threads when created through NamingThreadFactory with formated name.")
public void setsFormatedNameForThreads() {
final String nameFormat = "knownName-%d";
final String knownName1 = "knownName-0";
final String knownName2 = "knownName-1";
final ThreadFactory threadFactory = new NamingThreadFactory(nameFormat);
final Thread newThread1 = threadFactory.newThread(runnableMock);
final Thread newThread2 = threadFactory.newThread(runnableMock);
assertThat(newThread1.getName()).as("Name of the thread").isEqualTo(NamingThreadFactory.SP_PREFIX + knownName1);
assertThat(newThread2.getName()).as("Name of the thread").isEqualTo(NamingThreadFactory.SP_PREFIX + knownName2);
}
@Test
@Description("Created threads run are running.")
public void setsRunnableForThreads() {
final String knownName = "knownName";
final ThreadFactory threadFactory = new NamingThreadFactory(knownName);
final Thread newThread1 = threadFactory.newThread(runnableMock);
final Thread newThread2 = threadFactory.newThread(runnableMock);
newThread1.run();
newThread2.run();
verify(runnableMock, times(2)).run();
}
}

View File

@@ -38,10 +38,10 @@ public class SPUIComponentProviderTest {
// Checking Dyanmic Factory
Button placeHolderButton = null;
placeHolderButton = SPUIComponentProvider.getButton("", "Test", "Test",
SPUIButtonDefinitions.SP_BUTTON_STATUS_STYLE, true, null, SPUIButtonStyleSmallNoBorderUH.class);
SPUIDefinitions.SP_BUTTON_STATUS_STYLE, true, null, SPUIButtonStyleSmallNoBorderUH.class);
assertThat(placeHolderButton).isInstanceOf(SPUIButton.class);
assertThat(placeHolderButton.getCaption()).isEqualTo("Test");
assertThat(placeHolderButton.getStyleName()).isEqualTo(SPUIButtonDefinitions.SP_BUTTON_STATUS_STYLE);
assertThat(placeHolderButton.getStyleName()).isEqualTo(SPUIDefinitions.SP_BUTTON_STATUS_STYLE);
}
}