Merge branch 'master' into MECS-1277_clearing_the_search_field_should_keep_the_focus
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.artifacts.footer;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -21,6 +22,7 @@ import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout;
|
||||
import org.eclipse.hawkbit.ui.management.event.DragEvent;
|
||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -36,6 +38,7 @@ import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.Table;
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.Table.TableTransferable;
|
||||
|
||||
/**
|
||||
* Upload view footer layout implementation.
|
||||
@@ -196,7 +199,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
||||
final Component sourceComponent = event.getTransferable().getSourceComponent();
|
||||
if (sourceComponent instanceof Table) {
|
||||
final Table sourceTable = (Table) event.getTransferable().getSourceComponent();
|
||||
addToDeleteList(sourceTable);
|
||||
addToDeleteList(sourceTable,(TableTransferable) event.getTransferable());
|
||||
updateSWActionCount();
|
||||
}
|
||||
if (sourceComponent.getId().startsWith(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
|
||||
@@ -220,16 +223,23 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout {
|
||||
private void deleteSWModuleType(final String swModuleTypeName) {
|
||||
artifactUploadState.getSelectedDeleteSWModuleTypes().add(swModuleTypeName);
|
||||
}
|
||||
|
||||
private void addToDeleteList(final Table sourceTable) {
|
||||
final Set<Long> swModuleIds = (Set<Long>) sourceTable.getValue();
|
||||
swModuleIds.forEach(id -> {
|
||||
|
||||
private void addToDeleteList(final Table sourceTable, final TableTransferable transferable) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final Set<Long> swModuleSelected = (Set<Long>) sourceTable.getValue();
|
||||
final Set<Long> swModuleIdNameSet = new HashSet<Long>();
|
||||
if (!swModuleSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) {
|
||||
swModuleIdNameSet.add((Long) transferable.getData(SPUIDefinitions.ITEMID));
|
||||
} else {
|
||||
swModuleIdNameSet.addAll(swModuleSelected);
|
||||
}
|
||||
swModuleIdNameSet.forEach(id -> {
|
||||
final String swModuleName = (String) sourceTable.getContainerDataSource().getItem(id)
|
||||
.getItemProperty(SPUILabelDefinitions.NAME_VERSION).getValue();
|
||||
artifactUploadState.getDeleteSofwareModules().put(id, swModuleName);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the software module delete count.
|
||||
*/
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ui.filtermanagement;
|
||||
|
||||
|
||||
import java.awt.event.FocusListener;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -123,7 +121,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
private LayoutClickListener nameLayoutClickListner;
|
||||
|
||||
private boolean validationFailed = false;
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the Campaign Status History Header.
|
||||
*/
|
||||
@@ -149,20 +147,18 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
}
|
||||
|
||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
||||
void onEvent(final CustomFilterUIEvent custFUIEvent) {
|
||||
if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) {
|
||||
populateComponents();
|
||||
eventBus.publish(this, CustomFilterUIEvent.TARGET_DETAILS_VIEW);
|
||||
} else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
|
||||
setUpCaptionLayout(true);
|
||||
resetComponents();
|
||||
} else if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE) {
|
||||
this.getUI().access(() -> updateStatusIconAfterTablePopulated());
|
||||
}
|
||||
}
|
||||
void onEvent(final CustomFilterUIEvent custFUIEvent) {
|
||||
if (custFUIEvent == CustomFilterUIEvent.TARGET_FILTER_DETAIL_VIEW) {
|
||||
populateComponents();
|
||||
eventBus.publish(this, CustomFilterUIEvent.TARGET_DETAILS_VIEW);
|
||||
} else if (custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
|
||||
setUpCaptionLayout(true);
|
||||
resetComponents();
|
||||
} else if (custFUIEvent == CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON) {
|
||||
UI.getCurrent().access(() -> updateStatusIconAfterTablePopulated());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void populateComponents() {
|
||||
if (filterManagementUIState.getTfQuery().isPresent()) {
|
||||
queryTextField.setValue(filterManagementUIState.getTfQuery().get().getQuery());
|
||||
@@ -220,8 +216,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
|
||||
closeIcon = createSearchResetIcon();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private TextField createNameTextField() {
|
||||
final TextField nameField = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY, false, null,
|
||||
i18n.get("textfield.customfiltername"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
|
||||
@@ -331,22 +326,28 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
validationIcon.addStyleName("show-status-label");
|
||||
showValidationInProgress();
|
||||
onQueryChange(event.getText());
|
||||
executor.execute(new StatusCircledAsync());
|
||||
executor.execute(new StatusCircledAsync(UI.getCurrent()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
class StatusCircledAsync implements Runnable {
|
||||
private final UI current;
|
||||
|
||||
public StatusCircledAsync(final UI current) {
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
UI.setCurrent(current);
|
||||
eventBus.publish(this, CustomFilterUIEvent.FILTER_TARGET_BY_QUERY);
|
||||
}
|
||||
}
|
||||
|
||||
private void onQueryChange(final String text) {
|
||||
if (!Strings.isNullOrEmpty(text)) {
|
||||
final String input = text.toLowerCase();
|
||||
private void onQueryChange(final String input) {
|
||||
if (!Strings.isNullOrEmpty(input)) {
|
||||
final ValidationResult validationResult = FilterQueryValidation.getExpectedTokens(input);
|
||||
if (!validationResult.getIsValidationFailed()) {
|
||||
filterManagementUIState.setFilterQueryValue(input);
|
||||
@@ -361,17 +362,16 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
}
|
||||
enableDisableSaveButton(validationFailed, input);
|
||||
} else {
|
||||
setInitialStatusIconStyle(validationIcon);
|
||||
setInitialStatusIconStyle(validationIcon);
|
||||
filterManagementUIState.setFilterQueryValue(null);
|
||||
filterManagementUIState.setIsFilterByInvalidFilterQuery(Boolean.TRUE);
|
||||
}
|
||||
queryTextField.setValue(text);
|
||||
queryTextField.setValue(input);
|
||||
}
|
||||
|
||||
private void enableDisableSaveButton(final boolean validationFailed, final String query) {
|
||||
if (validationFailed
|
||||
|| (isNameAndQueryEmpty(nameTextField.getValue(), query) || (query.equals(oldFilterQuery) && nameTextField
|
||||
.getValue().equals(oldFilterName)))) {
|
||||
if (validationFailed || (isNameAndQueryEmpty(nameTextField.getValue(), query)
|
||||
|| (query.equals(oldFilterQuery) && nameTextField.getValue().equals(oldFilterName)))) {
|
||||
saveButton.setEnabled(false);
|
||||
} else {
|
||||
if (hasSavePermission()) {
|
||||
@@ -387,10 +387,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void showValidationSuccesIcon() {
|
||||
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
||||
validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
|
||||
validationIcon.setValue(FontAwesome.CHECK_CIRCLE.getHtml());
|
||||
validationIcon.setStyleName(SPUIStyleDefinitions.SUCCESS_ICON);
|
||||
}
|
||||
|
||||
private void showValidationFailureIcon() {
|
||||
@@ -471,8 +470,8 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
targetFilterQuery.setName(nameTextField.getValue());
|
||||
targetFilterQuery.setQuery(queryTextField.getValue());
|
||||
targetFilterQueryManagement.createTargetFilterQuery(targetFilterQuery);
|
||||
notification.displaySuccess(i18n.get("message.create.filter.success",
|
||||
new Object[] { targetFilterQuery.getName() }));
|
||||
notification.displaySuccess(
|
||||
i18n.get("message.create.filter.success", new Object[] { targetFilterQuery.getName() }));
|
||||
eventBus.publish(this, CustomFilterUIEvent.CREATE_TARGET_FILTER_QUERY);
|
||||
}
|
||||
|
||||
@@ -513,12 +512,12 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateStatusIconAfterTablePopulated() {
|
||||
queryTextField.focus();
|
||||
if (!validationFailed && !Strings.isNullOrEmpty(queryTextField.getValue())) {
|
||||
showValidationSuccesIcon();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateStatusIconAfterTablePopulated() {
|
||||
queryTextField.focus();
|
||||
if (!validationFailed && !Strings.isNullOrEmpty(queryTextField.getValue())) {
|
||||
showValidationSuccesIcon();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
import com.google.common.base.Strings;
|
||||
import com.vaadin.data.Item;
|
||||
import com.vaadin.server.FontAwesome;
|
||||
import com.vaadin.server.Sizeable.Unit;
|
||||
import com.vaadin.shared.ui.label.ContentMode;
|
||||
import com.vaadin.spring.annotation.SpringComponent;
|
||||
import com.vaadin.spring.annotation.ViewScope;
|
||||
@@ -101,18 +100,16 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
|| custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK) {
|
||||
UI.getCurrent().access(() -> populateTableData());
|
||||
} else if (custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
|
||||
this.getUI().access(() -> onQuery());
|
||||
UI.getCurrent().access(() -> onQuery());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void restoreOnLoad() {
|
||||
private void restoreOnLoad() {
|
||||
if (filterManagementUIState.isCreateFilterViewDisplayed()) {
|
||||
filterManagementUIState.setFilterQueryValue(null);
|
||||
} else {
|
||||
filterManagementUIState.getTfQuery().ifPresent(
|
||||
value -> filterManagementUIState.setFilterQueryValue(value.getQuery()));
|
||||
filterManagementUIState.getTfQuery()
|
||||
.ifPresent(value -> filterManagementUIState.setFilterQueryValue(value.getQuery()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,8 +125,9 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
targetQF.setQueryConfiguration(queryConfig);
|
||||
|
||||
// create lazy query container with lazy defination and query
|
||||
final LazyQueryContainer targetTableContainer = new LazyQueryContainer(new LazyQueryDefinition(true,
|
||||
SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME), targetQF);
|
||||
final LazyQueryContainer targetTableContainer = new LazyQueryContainer(
|
||||
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_CONT_ID_NAME),
|
||||
targetQF);
|
||||
targetTableContainer.getQueryView().getQueryDefinition().setMaxNestedPropertyDepth(PROPERTY_DEPT);
|
||||
|
||||
return targetTableContainer;
|
||||
@@ -182,16 +180,16 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
|
||||
private List<TableColumn> getVisbleColumns() {
|
||||
final List<TableColumn> columnList = new ArrayList<>();
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"),0.15f));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.NAME, i18n.get("header.name"), 0.15f));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"),
|
||||
0.1F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, i18n
|
||||
.get("header.assigned.ds"), 0.125F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, i18n
|
||||
.get("header.installed.ds"), 0.125F));
|
||||
columnList.add(
|
||||
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER,
|
||||
i18n.get("header.assigned.ds"), 0.125F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER,
|
||||
i18n.get("header.installed.ds"), 0.125F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F));
|
||||
columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F));
|
||||
return columnList;
|
||||
@@ -199,8 +197,8 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
|
||||
private Component getStatusIcon(final Object itemId) {
|
||||
final Item row1 = getItem(itemId);
|
||||
final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1.getItemProperty(
|
||||
SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
|
||||
final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1
|
||||
.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
|
||||
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
|
||||
label.setContentMode(ContentMode.HTML);
|
||||
if (targetStatus == TargetUpdateStatus.PENDING) {
|
||||
@@ -241,9 +239,9 @@ public class CreateOrUpdateFilterTable extends Table {
|
||||
protected void addCustomGeneratedColumns() {
|
||||
addGeneratedColumn(SPUILabelDefinitions.STATUS_ICON, (source, itemId, columnId) -> getStatusIcon(itemId));
|
||||
}
|
||||
|
||||
|
||||
private void onQuery() {
|
||||
populateTableData();
|
||||
eventBus.publish(this, CustomFilterUIEvent.TARGET_FILTER_STATUS_HIDE);
|
||||
}
|
||||
populateTableData();
|
||||
eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
/**
|
||||
*
|
||||
* Simple implementation of generics bean query which dynamically loads
|
||||
* {@link ProxyTarget} batch of beans.
|
||||
*
|
||||
*/
|
||||
public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
@@ -43,7 +44,6 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
private FilterManagementUIState filterManagementUIState;
|
||||
private transient I18N i18N;
|
||||
private String filterQuery;
|
||||
private Boolean isInvalidFilterQuery;
|
||||
|
||||
/**
|
||||
* Parametric Constructor.
|
||||
@@ -63,7 +63,6 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
|
||||
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
|
||||
filterQuery = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_QUERY);
|
||||
isInvalidFilterQuery = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_INVALID_QUERY);
|
||||
}
|
||||
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
|
||||
// Initalize Sor
|
||||
@@ -164,16 +163,11 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
final long totSize = getTargetManagement().countTargetsAll();
|
||||
long size;
|
||||
long size = 0;
|
||||
if (!Strings.isNullOrEmpty(filterQuery)) {
|
||||
size = getTargetManagement().countTargetByTargetFilterQuery(filterQuery);
|
||||
} else if (getFilterManagementUIState().isCreateFilterViewDisplayed() || isInvalidFilterQuery) {
|
||||
size = 0;
|
||||
} else {
|
||||
size = totSize;
|
||||
}
|
||||
getFilterManagementUIState().setTargetsCountAll(totSize);
|
||||
getFilterManagementUIState().setTargetsCountAll(size);
|
||||
if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) {
|
||||
getFilterManagementUIState().setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES);
|
||||
size = SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES;
|
||||
|
||||
@@ -15,5 +15,5 @@ package org.eclipse.hawkbit.ui.filtermanagement.event;
|
||||
*
|
||||
*/
|
||||
public enum CustomFilterUIEvent {
|
||||
FILTER_TARGET_BY_QUERY, FILTER_BY_CUST_FILTER_TEXT, FILTER_BY_CUST_FILTER_TEXT_REMOVE, CREATE_NEW_FILTER_CLICK, EXIT_CREATE_OR_UPDATE_FILTRER_VIEW, TARGET_FILTER_DETAIL_VIEW, TARGET_DETAILS_VIEW, CREATE_TARGET_FILTER_QUERY, UPDATED_TARGET_FILTER_QUERY, TARGET_FILTER_STATUS_HIDE
|
||||
FILTER_TARGET_BY_QUERY, FILTER_BY_CUST_FILTER_TEXT, FILTER_BY_CUST_FILTER_TEXT_REMOVE, CREATE_NEW_FILTER_CLICK, EXIT_CREATE_OR_UPDATE_FILTRER_VIEW, TARGET_FILTER_DETAIL_VIEW, TARGET_DETAILS_VIEW, CREATE_TARGET_FILTER_QUERY, UPDATED_TARGET_FILTER_QUERY, UPDATE_TARGET_FILTER_SEARCH_ICON
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.ui.filtermanagement.footer;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
|
||||
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
|
||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||
@@ -46,9 +45,6 @@ public class TargetFilterCountMessageLabel extends Label {
|
||||
@Autowired
|
||||
private FilterManagementUIState filterManagementUIState;
|
||||
|
||||
@Autowired
|
||||
private transient TargetManagement targetManagement;
|
||||
|
||||
@Autowired
|
||||
private I18N i18n;
|
||||
|
||||
@@ -75,7 +71,7 @@ public class TargetFilterCountMessageLabel extends Label {
|
||||
if (custFUIEvent == CustomFilterUIEvent.TARGET_DETAILS_VIEW
|
||||
|| custFUIEvent == CustomFilterUIEvent.CREATE_NEW_FILTER_CLICK
|
||||
|| custFUIEvent == CustomFilterUIEvent.EXIT_CREATE_OR_UPDATE_FILTRER_VIEW
|
||||
|| custFUIEvent == CustomFilterUIEvent.FILTER_TARGET_BY_QUERY) {
|
||||
|| custFUIEvent == CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON) {
|
||||
UI.getCurrent().access(() -> displayTargetFilterMessage());
|
||||
}
|
||||
}
|
||||
@@ -90,8 +86,7 @@ public class TargetFilterCountMessageLabel extends Label {
|
||||
long totalTargets = 0;
|
||||
if (filterManagementUIState.isCreateFilterViewDisplayed() || filterManagementUIState.isEditViewDisplayed()) {
|
||||
if (null != filterManagementUIState.getFilterQueryValue()) {
|
||||
totalTargets = targetManagement
|
||||
.countTargetByTargetFilterQuery(filterManagementUIState.getFilterQueryValue());
|
||||
totalTargets = filterManagementUIState.getTargetsCountAll().get();
|
||||
}
|
||||
final StringBuilder targetMessage = new StringBuilder(i18n.get("label.target.filtered.total"));
|
||||
if (filterManagementUIState.getTargetsTruncated() != null) {
|
||||
|
||||
@@ -19,24 +19,32 @@ 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("Component Tests - 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()).isEqualTo(NamingThreadFactory.SP_PREFIX + knownName);
|
||||
assertThat(newThread2.getName()).isEqualTo(NamingThreadFactory.SP_PREFIX + knownName);
|
||||
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";
|
||||
@@ -45,11 +53,12 @@ public class NamingThreadFactoryTest {
|
||||
final Thread newThread1 = threadFactory.newThread(runnableMock);
|
||||
final Thread newThread2 = threadFactory.newThread(runnableMock);
|
||||
|
||||
assertThat(newThread1.getName()).isEqualTo(NamingThreadFactory.SP_PREFIX + knownName1);
|
||||
assertThat(newThread2.getName()).isEqualTo(NamingThreadFactory.SP_PREFIX + knownName2);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user