Enabled target.assignedDs load through action enitygraph.

Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-02-16 17:37:34 +01:00
parent 38b750f674
commit 6a2b74e565
3 changed files with 20 additions and 3 deletions

View File

@@ -710,8 +710,8 @@ public class DeploymentManagement {
} }
/** /**
* Get the {@link Action} entity for given actionId with all lazy * Get the {@link Action} entity for given actionId with all lazy attributes
* attributes. * (i.e. distributionSet, target, target.assignedDs).
* *
* @param actionId * @param actionId
* to be id of the action * to be id of the action

View File

@@ -24,6 +24,7 @@ import javax.persistence.ManyToOne;
import javax.persistence.NamedAttributeNode; import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph; import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedEntityGraphs; import javax.persistence.NamedEntityGraphs;
import javax.persistence.NamedSubgraph;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
@@ -55,7 +56,7 @@ import org.eclipse.persistence.annotations.CascadeOnDelete;
@Index(name = "sp_idx_action_prim", columnList = "tenant,id") }) @Index(name = "sp_idx_action_prim", columnList = "tenant,id") })
@NamedEntityGraphs({ @NamedEntityGraph(name = "Action.ds", attributeNodes = { @NamedAttributeNode("distributionSet") }), @NamedEntityGraphs({ @NamedEntityGraph(name = "Action.ds", attributeNodes = { @NamedAttributeNode("distributionSet") }),
@NamedEntityGraph(name = "Action.all", attributeNodes = { @NamedAttributeNode("distributionSet"), @NamedEntityGraph(name = "Action.all", attributeNodes = { @NamedAttributeNode("distributionSet"),
@NamedAttributeNode("target") }) }) @NamedAttributeNode(value = "target", subgraph = "target.ds") }, subgraphs = @NamedSubgraph(name = "target.ds", attributeNodes = @NamedAttributeNode("assignedDistributionSet") ) ) })
@Entity @Entity
public class Action extends BaseEntity implements Comparable<Action> { public class Action extends BaseEntity implements Comparable<Action> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@@ -66,6 +66,22 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
@Autowired @Autowired
private EventBus eventBus; private EventBus eventBus;
@Test
@Description("Test verifies that the repistory retrieves the action including all defined (lazy) details.")
public void findActionWithLazyDetails() {
final DistributionSet testDs = TestDataUtil.generateDistributionSet("TestDs", "1.0", softwareManagement,
distributionSetManagement, new ArrayList<DistributionSetTag>());
final List<Target> testTarget = targetManagement.createTargets(TestDataUtil.generateTargets(1));
// one action with one action status is generated
final Action action = deploymentManagement.findActionWithDetails(
deploymentManagement.assignDistributionSet(testDs, testTarget).getActions().get(0));
assertThat(action.getDistributionSet()).as("DistributionSet in action").isNotNull();
assertThat(action.getTarget()).as("Target in action").isNotNull();
assertThat(action.getTarget().getAssignedDistributionSet()).as("AssignedDistributionSet of target in action")
.isNotNull();
}
@Test @Test
@Description("Test verifies that the custom query to find all actions include the count of action status is working correctly") @Description("Test verifies that the custom query to find all actions include the count of action status is working correctly")
public void findActionsWithStatusCountByTarget() { public void findActionsWithStatusCountByTarget() {