Fix installedBase link in DDI base resource (#1232)

* add test for installedBase bug

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* fix for test scenario I

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* add another test scenario for installedbase bug

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* add fix for scenario 2a+b

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>
This commit is contained in:
Natalia Kislicyn
2022-02-22 15:09:51 +01:00
committed by GitHub
parent cc60725c08
commit 681df6c1f1
4 changed files with 173 additions and 6 deletions

View File

@@ -190,16 +190,19 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction, Long>,
List<Action> findActionByTargetAndSoftwareModule(@Param("target") String targetId, @Param("module") Long moduleId);
/**
* Retrieves latest {@link Action} for given target and {@link DistributionSet}.
* Retrieves the latest finished {@link Action} for given target and {@link DistributionSet}.
*
* @param targetId
* to search for
* the action belongs to
* @param dsId
* to search for
* of the ds that is assigned to the target
* @param status
* of the action
* @return action if there is one with assigned target and assigned
* {@link DistributionSet}.
*/
Optional<Action> findFirstByTargetIdAndDistributionSetId(@Param("target") long targetId, @Param("ds") Long dsId);
Optional<Action> findFirstByTargetIdAndDistributionSetIdAndStatusOrderByIdDesc(@Param("target") long targetId,
@Param("ds") Long dsId, @Param("status") Action.Status status);
/**
* Retrieves all {@link Action}s which are referring the given

View File

@@ -1067,8 +1067,8 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
final JpaDistributionSet installedDistributionSet = jpaTarget.getInstalledDistributionSet();
if (null != installedDistributionSet) {
return actionRepository.findFirstByTargetIdAndDistributionSetId(jpaTarget.getId(),
installedDistributionSet.getId());
return actionRepository.findFirstByTargetIdAndDistributionSetIdAndStatusOrderByIdDesc(jpaTarget.getId(),
installedDistributionSet.getId(), FINISHED);
} else {
return Optional.empty();
}