-
Notifications
You must be signed in to change notification settings - Fork 220
fix(teams): trim team names on xls import and allow deleting teams linked to injects (#7558) #7609
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
base: main
Are you sure you want to change the base?
Changes from all commits
6addb54
9ae22c5
7dff1ba
eed0056
452882f
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 |
|---|---|---|
|
|
@@ -244,11 +244,13 @@ public Team upsertTeam(@Valid @RequestBody TeamCreateInput input) { | |
| @Transactional | ||
| public void deleteTeam(@PathVariable @Schema(description = "ID of the team") String teamId) | ||
| throws ResourceInUseException { | ||
| if (!teamRepository.existsByIdAndTenantId(teamId, TenantContext.getCurrentTenant())) { | ||
| throw new ElementNotFoundException(); | ||
| } | ||
| Team team = | ||
|
Member
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. TODO: can you test on bulk delete team if we have the issue? |
||
| teamRepository | ||
| .findByIdAndTenantId(teamId, TenantContext.getCurrentTenant()) | ||
| .orElseThrow(ElementNotFoundException::new); | ||
| try { | ||
| teamRepository.deleteById(teamId); | ||
| team.getInjects().forEach(inject -> inject.getTeams().remove(team)); | ||
| teamRepository.delete(team); | ||
|
Comment on lines
+247
to
+253
|
||
| } catch (InvalidDataAccessApiUsageException | TransientObjectException ex) { | ||
| throw new ResourceInUseException( | ||
| "Cannot delete this team because it is still in use. Please remove its dependencies first.", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,16 +13,16 @@ | |
| import io.openaev.database.repository.ScenarioRepository; | ||
| import io.openaev.rest.exception.ElementNotFoundException; | ||
| import io.openaev.utils.InjectImportUtils; | ||
| import io.openaev.utils.fixtures.XlsFixture; | ||
| import io.openaev.utils.mockMapper.MockMapperUtils; | ||
| import java.text.SimpleDateFormat; | ||
| import java.time.LocalDateTime; | ||
| import java.time.LocalTime; | ||
| import java.time.ZoneOffset; | ||
| import java.time.format.DateTimeFormatter; | ||
| import java.time.temporal.Temporal; | ||
| import java.util.Date; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import java.util.*; | ||
| import java.util.stream.Collectors; | ||
| import org.apache.poi.ss.usermodel.Cell; | ||
| import org.apache.poi.ss.usermodel.Row; | ||
| import org.apache.poi.ss.usermodel.Sheet; | ||
|
|
@@ -235,6 +235,33 @@ void testExtractWithoutConvertingCellAsHTML() { | |
| assertEquals("Test\nTest", result); | ||
| } | ||
|
|
||
| @DisplayName("Test parse teams cell with spaces and trailing comma") | ||
| @Test | ||
| void testParseTeamsCellWithSpacesAndTrailingComma() { | ||
|
Member
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. TODO: this test don't test your changes. Please do a real import. |
||
| // -- PREPARE -- | ||
| XlsFixture lsFixture = new XlsFixture(); | ||
| workbook = lsFixture.createXlsFileWithTeams("Team A,\n Team A , Team_B,"); | ||
| Sheet sheet = workbook.getSheetAt(0); | ||
| row = sheet.getRow(0); | ||
| RuleAttribute ruleAttribute = MockMapperUtils.createRuleAttribute(); | ||
| ruleAttribute.setColumns("A"); | ||
|
|
||
| // -- EXECUTE -- | ||
| List<String> columnValues = | ||
| Arrays.stream( | ||
| Arrays.stream(ruleAttribute.getColumns().split("\\+")) | ||
| .map(column -> InjectImportUtils.getValueAsString(row, column)) | ||
| .collect(Collectors.joining(",")) | ||
| .split(",")) | ||
| .map(String::trim) | ||
| .filter(value -> !value.isBlank()) | ||
| .distinct() | ||
|
Member
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. todo: that's a huge issue. Having a disctinct here instead of having it on the prod code. Please put the distinct method in openaev-api/src/main/java/io/openaev/service/InjectImportService.java |
||
| .toList(); | ||
|
|
||
| // -- ASSERT -- | ||
| assertEquals(List.of("Team A", "Team_B"), columnValues); | ||
| } | ||
|
|
||
| @DisplayName("Test get inject date without pattern but with an ISO_DATE_TIME format") | ||
| @Test | ||
| void testGetInjectDateWithoutPattern() { | ||
|
|
||
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.
Todo: you should add a test for this case.