-
Notifications
You must be signed in to change notification settings - Fork 90
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
[backend/frontend] Restarting an atomic testing keeps the same Inject UUID #1901
Conversation
e4a1047
to
cb41d05
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/1.10.0 #1901 +/- ##
====================================================
+ Coverage 33.62% 34.10% +0.48%
- Complexity 1671 1700 +29
====================================================
Files 572 572
Lines 16697 16718 +21
Branches 970 969 -1
====================================================
+ Hits 5614 5702 +88
+ Misses 10829 10756 -73
- Partials 254 260 +6 ☔ View full report in Codecov by Sentry. |
f7e1608
to
2db9515
Compare
public InjectResultOverviewOutput launchAtomicTesting( | ||
@PathVariable @NotBlank final String atomicTestingId) { | ||
return atomicTestingService.launch(atomicTestingId); | ||
} |
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.
The API routes are much clearer now, thank you!
@isselparra When I try to relaunch an atomic test, I consistently encounter a 500 error. It seems like there might be an issue on the backend. |
@Transactional | ||
public InjectResultOverviewOutput duplicate(String id) { | ||
Inject injectOrigin = injectRepository.findById(id).orElseThrow(ElementNotFoundException::new); | ||
Inject duplicatedInject = InjectUtils.duplicateInject(injectOrigin); | ||
duplicatedInject.setTitle(duplicateString(duplicatedInject.getTitle())); | ||
Inject savedInject = injectRepository.save(duplicatedInject); | ||
return injectMapper.toInjectResultOverviewOutput(savedInject); | ||
} | ||
|
||
@Transactional | ||
public InjectResultOverviewOutput launch(String id) { | ||
Inject inject = injectRepository.findById(id).orElseThrow(ElementNotFoundException::new); | ||
inject.clean(); | ||
inject.setUpdatedAt(Instant.now()); | ||
|
||
InjectStatus injectStatus = setInjectStatusAsQueuing(inject); | ||
inject.setStatus(injectStatus); | ||
|
||
return injectMapper.toInjectResultOverviewOutput(injectRepository.save(inject)); | ||
} | ||
|
||
@Transactional | ||
public InjectResultOverviewOutput relaunch(String id) { | ||
Inject injectOrigin = injectRepository.findById(id).orElseThrow(ElementNotFoundException::new); | ||
Inject duplicatedInject = InjectUtils.duplicateInject(injectOrigin); | ||
|
||
Inject savedInject = injectRepository.save(duplicatedInject); | ||
|
||
InjectStatus injectStatus = setInjectStatusAsQueuing(savedInject); | ||
savedInject.setStatus(injectStatus); | ||
|
||
injectDocumentRepository.deleteDocumentsFromInject(id); | ||
injectRepository.deleteById(id); | ||
|
||
return injectMapper.toInjectResultOverviewOutput(injectRepository.save(savedInject)); | ||
} |
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.
issue: we should avoid duplicating too much code, perhaps we could encapsulate some behaviour
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.
I mutualise as much as possible some behaviors
Let me know if you have any other suggestions
openbas-api/src/test/java/io/openbas/rest/AtomicTestingApiTest.java
Outdated
Show resolved
Hide resolved
cce443e
to
e651b10
Compare
@MarineLeM I fixed the problem you were having with the relaunch of an Inject |
openbas-api/src/main/java/io/openbas/rest/atomic_testing/AtomicTestingApi.java
Show resolved
Hide resolved
openbas-front/src/admin/components/atomic_testings/atomic_testing/AtomicTestingHeader.tsx
Show resolved
Hide resolved
f6dab08
to
36a7099
Compare
Proposed changes
Atomic Testing
API changes:
Atomic testing duplication route
Before:
@PostMapping("/{atomicTestingId}")
After:
@PostMapping("/{atomicTestingId}/duplicate")
Atomic testing launching route
Before:
@GetMapping("/try/{injectId}")
After:
@PostMapping("/{atomicTestingId}/launch")
Atomic testing relaunching route (new)
@PostMapping("/{atomicTestingId}/relaunch")
Inject launching (deleted)
Not used in the app
@GetMapping("/api/injects/try/{injectId}")
Refactor:
Change
InjectDuplicateService
to reduce the number of db callsRelated issues
Checklist
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...