-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge hotfix/5.11.1 #1973
Merge hotfix/5.11.1 #1973
Changes from all commits
9701da3
7024166
3dcf60a
30612d7
5f92284
f056315
e25059f
f88d8ab
13d6e16
929006d
9013748
68ebccd
a3e183f
ef9d00b
f0e8cbb
afb083d
3c970ce
6f65e2d
0c426d5
4d0e3e9
6b0ec09
375862e
53f8a90
fbc5e29
00435ff
d328565
b78ea18
9d71a7f
b39dadd
9f4b2cc
f61d886
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ | |
import org.apache.commons.lang3.StringUtils; | ||
import org.pf4j.PluginDescriptor; | ||
import org.pf4j.PluginDescriptorFinder; | ||
import org.pf4j.PluginException; | ||
import org.pf4j.PluginRuntimeException; | ||
import org.pf4j.PluginWrapper; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
@@ -87,7 +87,7 @@ public PluginLoaderImpl(DataStore dataStore, IntegrationTypeRepository integrati | |
|
||
@Override | ||
@NotNull | ||
public PluginInfo extractPluginInfo(Path pluginPath) throws PluginException { | ||
public PluginInfo extractPluginInfo(Path pluginPath) throws PluginRuntimeException { | ||
PluginDescriptor pluginDescriptor = pluginDescriptorFinder.find(pluginPath); | ||
return new PluginInfo(pluginDescriptor.getPluginId(), pluginDescriptor.getVersion()); | ||
} | ||
|
@@ -99,8 +99,7 @@ public IntegrationTypeDetails resolvePluginDetails(PluginInfo pluginInfo) { | |
.flatMap(it -> ofNullable(it.getDetails())).flatMap( | ||
typeDetails -> IntegrationTypeProperties.VERSION.getValue(typeDetails.getDetails()) | ||
.map(String::valueOf)).ifPresent( | ||
version -> BusinessRule.expect(version, v -> !v.equalsIgnoreCase( | ||
pluginInfo.getVersion())) | ||
version -> BusinessRule.expect(version, v -> !v.equalsIgnoreCase(pluginInfo.getVersion())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
.verify( | ||
ErrorType.PLUGIN_UPLOAD_ERROR, Suppliers.formattedSupplier( | ||
"Plugin with ID = '{}' of the same VERSION = '{}' " | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
import com.epam.ta.reportportal.commons.querygen.Queryable; | ||
import com.epam.ta.reportportal.entity.jasper.ReportFormat; | ||
import com.epam.ta.reportportal.entity.project.Project; | ||
import com.epam.ta.reportportal.entity.user.UserRole; | ||
import com.epam.ta.reportportal.model.project.ProjectResource; | ||
import com.epam.ta.reportportal.model.user.SearchUserResource; | ||
import com.epam.ta.reportportal.model.user.UserResource; | ||
|
@@ -88,6 +89,7 @@ public interface GetProjectHandler { | |
* @return List of found user resources | ||
*/ | ||
Iterable<SearchUserResource> getUserNames(String value, | ||
UserRole userRole, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
ReportPortalUser.ProjectDetails projectDetails, Pageable pageable); | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
import com.epam.ta.reportportal.entity.project.ProjectInfo; | ||
import com.epam.ta.reportportal.entity.user.User; | ||
import com.epam.reportportal.rules.exception.ReportPortalException; | ||
import com.epam.ta.reportportal.entity.user.UserRole; | ||
import com.epam.ta.reportportal.model.project.ProjectResource; | ||
import com.epam.ta.reportportal.model.user.SearchUserResource; | ||
import com.epam.ta.reportportal.model.user.UserResource; | ||
|
@@ -60,6 +61,7 @@ | |
import org.jooq.Operator; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Service; | ||
|
@@ -82,6 +84,9 @@ public class GetProjectHandlerImpl implements GetProjectHandler { | |
|
||
private final ProjectConverter projectConverter; | ||
|
||
@Value("${rp.environment.variable.user.suggestions:true}") | ||
boolean isUserSuggestions; | ||
|
||
@Autowired | ||
public GetProjectHandlerImpl(ProjectRepository projectRepository, UserRepository userRepository, | ||
@Qualifier("projectJasperReportHandler") | ||
|
@@ -161,10 +166,12 @@ private void checkBusinessRuleLessThan1Symbol(String value) { | |
|
||
@Override | ||
public Iterable<SearchUserResource> getUserNames(String value, | ||
ReportPortalUser.ProjectDetails projectDetails, Pageable pageable) { | ||
UserRole userRole,ReportPortalUser.ProjectDetails projectDetails, Pageable pageable) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
checkBusinessRuleLessThan1Symbol(value); | ||
|
||
final CompositeFilterCondition userCondition = getUserSearchCondition(value); | ||
final CompositeFilterCondition userCondition = | ||
(userRole.equals(UserRole.ADMINISTRATOR) || isUserSuggestions) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
? getUserSearchSuggestCondition(value) : getUserSearchCondition(value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
final Filter filter = Filter.builder().withTarget(User.class).withCondition(userCondition) | ||
.withCondition( | ||
|
@@ -176,13 +183,18 @@ public Iterable<SearchUserResource> getUserNames(String value, | |
.apply(userRepository.findByFilterExcludingProjects(filter, pageable)); | ||
} | ||
|
||
private CompositeFilterCondition getUserSearchCondition(String value) { | ||
return new CompositeFilterCondition( | ||
List.of(new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_USER), | ||
new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_FULL_NAME), | ||
new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_EMAIL) | ||
), Operator.AND); | ||
} | ||
private CompositeFilterCondition getUserSearchSuggestCondition(String value) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return new CompositeFilterCondition(List.of(new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_USER), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_FULL_NAME), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_EMAIL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
), Operator.AND); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
private CompositeFilterCondition getUserSearchCondition(String value) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return new CompositeFilterCondition(List.of( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
new FilterCondition(Operator.OR, Condition.EQUALS, false, value, CRITERIA_EMAIL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
), Operator.AND); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
@Override | ||
public List<String> getAllProjectNames() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,18 +39,22 @@ | |
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.Spy; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Ihar Kahadouski</a> | ||
*/ | ||
@ExtendWith(MockitoExtension.class) | ||
@TestPropertySource(properties = {"rp.environment.variable.user.suggestions=true"}) | ||
class GetProjectHandlerImplTest { | ||
|
||
@Mock | ||
private ProjectRepository projectRepository; | ||
|
||
@Spy | ||
@InjectMocks | ||
private GetProjectHandlerImpl handler; | ||
|
||
|
@@ -124,17 +128,11 @@ void getUserNamesByIncorrectTerm() { | |
); | ||
} | ||
|
||
@Test | ||
void getUserNamesNegative() { | ||
ReportPortalException exception = assertThrows( | ||
ReportPortalException.class, () -> handler.getUserNames("", | ||
new ReportPortalUser.ProjectDetails(1L, "superadmin_personal", | ||
ProjectRole.PROJECT_MANAGER | ||
), PageRequest.of(0, 10) | ||
)); | ||
assertEquals( | ||
"Incorrect filtering parameters. Length of the filtering string '' is less than 1 symbol", | ||
exception.getMessage() | ||
); | ||
} | ||
@Test | ||
void getUserNamesNegative() { | ||
ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.getUserNames("", UserRole.ADMINISTRATOR, | ||
new ReportPortalUser.ProjectDetails(1L, "superadmin_personal", ProjectRole.PROJECT_MANAGER), | ||
PageRequest.of(0, 10))); | ||
assertEquals("Incorrect filtering parameters. Length of the filtering string '' is less than 1 symbol", exception.getMessage()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is longer than 100 characters (found 127).