@Override
public Object provide() {
- return Arrays.asList(BatchService.class, ServerService.class);
+ return Arrays.<Object> asList(BatchService.class, ServerService.class);
}
}
@Test
public void shouldFailIfCantGetServerId() throws Exception {
- when(remoteServerMetadata.getServerId()).thenThrow(IOException.class);
+ when(remoteServerMetadata.getServerId()).thenThrow(new IOException());
thrown.expect(SonarException.class);
thrown.expectMessage("Impossible to get the ID of the remote server: http://localhost:9000");
* @since 3.1
*/
public final class CriterionDto {
- private Long id;
private Long filterId;
private String family;
private String key;
private String textValue;
private Boolean variation;
- public Long getId() {
- return id;
- }
-
- public CriterionDto setId(Long id) {
- this.id = id;
- return this;
- }
-
- public Long getFilterId() {
- return filterId;
- }
-
+ /**
+ * @param filterId the filter id to set
+ */
public CriterionDto setFilterId(Long filterId) {
this.filterId = filterId;
return this;
}
- public String getFamily() {
- return family;
- }
-
+ /**
+ * @param family the family to set
+ */
public CriterionDto setFamily(String family) {
this.family = family;
return this;
}
- public String getKey() {
- return key;
- }
-
+ /**
+ * @param key the key to set
+ */
public CriterionDto setKey(String key) {
this.key = key;
return this;
}
- public String getOperator() {
- return operator;
- }
-
+ /**
+ * @param operator the operator to set
+ */
public CriterionDto setOperator(String operator) {
this.operator = operator;
return this;
}
- public Float getValue() {
- return value;
- }
-
+ /**
+ * @param value the value to set
+ */
public CriterionDto setValue(Float value) {
this.value = value;
return this;
}
- public String getTextValue() {
- return textValue;
- }
-
+ /**
+ * @param textValue the textValue to set
+ */
public CriterionDto setTextValue(String textValue) {
this.textValue = textValue;
return this;
}
- public Boolean getVariation() {
- return variation;
- }
-
+ /**
+ * @param variation the variation to set
+ */
public CriterionDto setVariation(Boolean variation) {
this.variation = variation;
return this;
* @since 3.1
*/
public interface CriterionMapper {
- void insert(CriterionDto criteriaDto);
+ /**
+ * Insert a {@link CriterionDto}.
+ *
+ * @param criterionDto the criterion to insert
+ */
+ void insert(CriterionDto criterionDto);
}
* @since 3.1
*/
public final class FilterColumnDto {
- private Long id;
private Long filterId;
private String family;
private String key;
private Long orderIndex;
private Boolean variation;
- public Long getId() {
- return id;
- }
-
- public FilterColumnDto setId(Long id) {
- this.id = id;
- return this;
- }
-
- public Long getFilterId() {
- return filterId;
- }
-
+ /**
+ * @param filterId the filterId to set
+ */
public FilterColumnDto setFilterId(Long filterId) {
this.filterId = filterId;
return this;
}
- public String getFamily() {
- return family;
- }
-
+ /**
+ * @param family the family to set
+ */
public FilterColumnDto setFamily(String family) {
this.family = family;
return this;
}
- public String getKey() {
- return key;
- }
-
+ /**
+ * @param key the key to set
+ */
public FilterColumnDto setKey(String key) {
this.key = key;
return this;
}
- public String getSortDirection() {
- return sortDirection;
- }
-
+ /**
+ * @param sortDirection the sortDirection to set
+ */
public FilterColumnDto setSortDirection(String sortDirection) {
this.sortDirection = sortDirection;
return this;
}
- public Long getOrderIndex() {
- return orderIndex;
- }
-
+ /**
+ * @param orderIndex the orderIndex to set
+ */
public FilterColumnDto setOrderIndex(Long orderIndex) {
this.orderIndex = orderIndex;
return this;
}
- public Boolean getVariation() {
- return variation;
- }
-
+ /**
+ * @param variation the variation to set
+ */
public FilterColumnDto setVariation(Boolean variation) {
this.variation = variation;
return this;
* @since 3.1
*/
public interface FilterColumnMapper {
+ /**
+ * Insert a {@link FilterColumnDto}.
+ *
+ * @param filterColumnDto the filter column to insert
+ */
void insert(FilterColumnDto filterColumnDto);
}
private List<CriterionDto> criteria = Lists.newArrayList();
private List<FilterColumnDto> filterColumns = Lists.newArrayList();
+ /**
+ * @return the id
+ */
public Long getId() {
return id;
}
- public FilterDto setId(Long id) {
- this.id = id;
- return this;
- }
-
+ /**
+ * @return the name
+ */
public String getName() {
return name;
}
+ /**
+ * @param name the name to set
+ */
public FilterDto setName(String name) {
this.name = name;
return this;
}
+ /**
+ * @return the key
+ */
public String getKey() {
return key;
}
+ /**
+ * @param key the key to set
+ */
public FilterDto setKey(String key) {
this.key = key;
return this;
}
- public Long getUserId() {
- return userId;
- }
-
- public FilterDto setUserId(Long userId) {
- this.userId = userId;
- return this;
- }
-
+ /**
+ * @return <code>true</code> if the filter is shared
+ */
public Boolean isShared() {
return shared;
}
+ /**
+ * @param shared the shared to set
+ */
public FilterDto setShared(Boolean shared) {
this.shared = shared;
return this;
}
+ /**
+ * @return <code>true</code> if the filter displays only favourite resources.
+ */
public Boolean isFavourites() {
return favourites;
}
+ /**
+ * @param favourites the favourites to set
+ */
public FilterDto setFavourites(Boolean favourites) {
this.favourites = favourites;
return this;
}
- public Long getResourceId() {
- return resourceId;
- }
-
- public FilterDto setResourceId(Long resourceId) {
- this.resourceId = resourceId;
- return this;
- }
-
+ /**
+ * @return the defaut view
+ */
public String getDefaultView() {
return defaultView;
}
+ /**
+ * @param defaultView the defaultView to set
+ */
public FilterDto setDefaultView(String defaultView) {
this.defaultView = defaultView;
return this;
}
+ /**
+ * @return the page size
+ */
public Long getPageSize() {
return pageSize;
}
return this;
}
- public Long getPeriodIndex() {
- return periodIndex;
- }
-
- public FilterDto setPeriodIndex(Long periodIndex) {
- this.periodIndex = periodIndex;
- return this;
- }
-
+ /**
+ * @return the criterion list
+ */
public Collection<CriterionDto> getCriteria() {
return criteria;
}
+ /**
+ * Add a {@link CriterionDto} to the list.
+ *
+ * @param criterion the criterion to add
+ */
public FilterDto add(CriterionDto criterion) {
criteria.add(criterion);
return this;
}
+ /**
+ * @return the column list
+ */
public Collection<FilterColumnDto> getColumns() {
return filterColumns;
}
+ /**
+ * Add a {@link FilterColumnDto} to the list.
+ *
+ * @param filterColumn the column to add
+ */
public FilterDto add(FilterColumnDto filterColumn) {
filterColumns.add(filterColumn);
return this;
* @since 3.1
*/
public interface FilterMapper {
- FilterDto findFilter(String name);
+ /**
+ * Find a {@link FilterDto} by its unique key.
+ *
+ * @param key the key to search on
+ * @return the filter
+ */
+ FilterDto findFilter(String key);
+ /**
+ * Insert a {@link FilterDto}.
+ *
+ * @param filterDto the filter to insert
+ */
void insert(FilterDto filterDto);
}
return settings.hasKey(getPropertyKey()) || settings.getDefaultValue(getPropertyKey()) != null;
}
+ @Override
public String toString() {
return "Property " + getPropertyKey() + " must be set";
}
*/
package org.sonar.core.filters;
-import org.sonar.core.filter.FilterColumnDto;
-
-import org.sonar.core.filter.CriterionDto;
-
import org.junit.Before;
import org.junit.Test;
+import org.sonar.core.filter.CriterionDto;
+import org.sonar.core.filter.FilterColumnDto;
import org.sonar.core.filter.FilterDao;
import org.sonar.core.filter.FilterDto;
import org.sonar.core.persistence.DaoTestCase;
assertThat(filter.getId()).isEqualTo(1L);
assertThat(filter.getName()).isEqualTo("Projects");
assertThat(filter.getKey()).isEqualTo("Projects");
- assertThat(filter.getUserId()).isNull();
assertThat(dao.findFilter("<UNKNOWN>")).isNull();
}
FilterDto filterDto = new FilterDto();
filterDto.setName("Projects");
filterDto.setKey("Projects");
- filterDto.setUserId(null);
filterDto.setShared(true);
filterDto.setFavourites(false);
- filterDto.setResourceId(null);
filterDto.setDefaultView("list");
filterDto.setPageSize(10L);
- filterDto.setPeriodIndex(1L);
CriterionDto criterionDto = new CriterionDto();
criterionDto.setFamily("family");
*/
package org.sonar.core.resource;
+import org.fest.assertions.Assertions;
+
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.core.Is;
resource_id="[null]"
default_view="list"
page_size="10"
- period_index="1"
+ period_index="[null]"
/>
<criteria
*
* @since 3.1
*/
-public class Criterion {
+public final class Criterion {
public static final String EQ = "=";
public static final String GT = ">";
public static final String GTE = ">=";
*
* @since 3.1
*/
-public class Filter {
+public final class Filter {
public static final String LIST = "list";
public static final String TREEMAP = "treemap";
*
* @since 3.1
*/
-public class FilterColumn {
+public final class FilterColumn {
public static final String ASC = "ASC";
public static final String DESC = "DESC";
public static final Set<String> DIRECTIONS = ImmutableSortedSet.of(ASC, DESC);
private DashboardDao dashboardDao;
private ActiveDashboardDao activeDashboardDao;
private LoadedTemplateDao loadedTemplateDao;
- private RegisterNewFilters registerNewFilters; // To force loading the filters before the dashboards
- public RegisterNewDashboards(DashboardDao dashboardDao, ActiveDashboardDao activeDashboardDao, LoadedTemplateDao loadedTemplateDao, RegisterNewFilters registerNewFilters) {
- this(new DashboardTemplate[] {}, dashboardDao, activeDashboardDao, loadedTemplateDao, registerNewFilters);
+ public RegisterNewDashboards(DashboardDao dashboardDao, ActiveDashboardDao activeDashboardDao, LoadedTemplateDao loadedTemplateDao) {
+ this(new DashboardTemplate[] {}, dashboardDao, activeDashboardDao, loadedTemplateDao);
}
public RegisterNewDashboards(DashboardTemplate[] dashboardTemplatesArray, DashboardDao dashboardDao,
- ActiveDashboardDao activeDashboardDao, LoadedTemplateDao loadedTemplateDao,
- RegisterNewFilters registerNewFilters) {
+ ActiveDashboardDao activeDashboardDao, LoadedTemplateDao loadedTemplateDao) {
this.dashboardTemplates = Lists.newArrayList(dashboardTemplatesArray);
this.dashboardDao = dashboardDao;
this.activeDashboardDao = activeDashboardDao;
this.loadedTemplateDao = loadedTemplateDao;
- this.registerNewFilters = registerNewFilters;
}
public void start() {
for (FilterTemplate template : filterTemplates) {
if (shouldRegister(template.getName())) {
Filter filter = template.createFilter();
- FilterDto dto = register(template.getName(), filter);
+ register(template.getName(), filter);
}
}
return dto;
}
- private static void addCriteria(FilterDto filterDto, String family, String operator, String textValue) {
- if (textValue != null) {
- filterDto.add(new CriterionDto().setFamily(family).setOperator(operator).setTextValue(textValue));
- }
- }
-
protected FilterDto createDtoFromExtension(String name, Filter filter) {
FilterDto filterDto = new FilterDto()
.setName(name)
@Override
public Object provide() {
- return Arrays.asList(FakeBatchExtension.class, FakeServerExtension.class);
+ return Arrays.<Object> asList(FakeBatchExtension.class, FakeServerExtension.class);
}
}
@Override
public Object provide() {
- return Arrays.asList(FakeBatchExtension.class, FakeServerExtension.class);
+ return Arrays.<Object> asList(FakeBatchExtension.class, FakeServerExtension.class);
}
}
import org.sonar.api.web.Dashboard;
import org.sonar.api.web.DashboardLayout;
import org.sonar.api.web.DashboardTemplate;
-import org.sonar.core.dashboard.*;
+import org.sonar.core.dashboard.ActiveDashboardDao;
+import org.sonar.core.dashboard.ActiveDashboardDto;
+import org.sonar.core.dashboard.DashboardDao;
+import org.sonar.core.dashboard.DashboardDto;
+import org.sonar.core.dashboard.WidgetDto;
+import org.sonar.core.dashboard.WidgetPropertyDto;
import org.sonar.core.template.LoadedTemplateDao;
import org.sonar.core.template.LoadedTemplateDto;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.argThat;
import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class RegisterNewDashboardsTest {
fakeDashboardTemplate = new FakeDashboard();
task = new RegisterNewDashboards(new DashboardTemplate[]{fakeDashboardTemplate}, dashboardDao,
- activeDashboardDao, loadedTemplateDao, null);
+ activeDashboardDao, loadedTemplateDao);
}
@Test
FilterDto dto = register.createDtoFromExtension("Fake", filterTemplate.createFilter());
- assertThat(dto.getUserId()).isNull();
assertThat(dto.getName()).isEqualTo("Fake");
assertThat(dto.getKey()).isEqualTo("Fake");
assertThat(dto.isShared()).isTrue();