• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

common-workflow-language / cwlviewer / #1836

29 Apr 2025 11:40AM UTC coverage: 70.334% (+0.03%) from 70.306%
#1836

push

github

mr-c
Add a test for workflow repository

1707 of 2427 relevant lines covered (70.33%)

0.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.33
/src/main/java/org/commonwl/view/workflow/QueuedWorkflowRepositoryImpl.java
1
package org.commonwl.view.workflow;
2

3
import io.hypersistence.utils.hibernate.type.json.JsonType;
4
import jakarta.persistence.EntityManager;
5
import jakarta.persistence.PersistenceContext;
6
import jakarta.persistence.PersistenceContextType;
7
import org.commonwl.view.git.GitDetails;
8
import org.hibernate.query.Query;
9
import org.springframework.transaction.annotation.Transactional;
10

11
public class QueuedWorkflowRepositoryImpl implements QueuedWorkflowRepositoryCustom {
1✔
12

13
  private static final String QUERY_FIND_BY_RETRIEVED_FROM =
14
      "SELECT q.* FROM queued_workflow q WHERE q.temp_representation -> 'retrievedFrom' = :retrievedFrom";
15

16
  private static final String QUERY_DELETE_BY_RETRIEVED_FROM =
17
      "DELETE FROM queued_workflow q WHERE q.temp_representation -> 'retrievedFrom' = :retrievedFrom";
18

19
  @PersistenceContext(type = PersistenceContextType.EXTENDED)
20
  EntityManager entityManager;
21

22
  @Override
23
  public QueuedWorkflow findByRetrievedFrom(GitDetails retrievedFrom) {
24
    // N.B. The migration from Spring Boot 2 to 3 got blocked for a while as
25
    //      we couldn't figure out a way to get the mapping of types to work.
26
    //      We always ended up the error about the invalid operator for the
27
    //      jsonb = bytea types. Found this comment from the author of the
28
    //      mapping library we use, with what was the fix for our issue (ran
29
    //      out of ideas, so started testing everything found online):
30
    //      Use `new JsonType(GitDetails.class)`. That finally solved it.
31
    //      Ref: https://github.com/common-workflow-language/cwlviewer/pull/568
32
    final Query<?> query =
1✔
33
        entityManager
34
            .createNativeQuery(QUERY_FIND_BY_RETRIEVED_FROM, QueuedWorkflow.class)
1✔
35
            .unwrap(Query.class);
1✔
36

37
    if (query == null) {
1✔
38
      return null;
×
39
    }
40

41
    query.setParameter("retrievedFrom", retrievedFrom, new JsonType(GitDetails.class));
1✔
42
    return (QueuedWorkflow) query.uniqueResult();
1✔
43
  }
44

45
  @Transactional
46
  @Override
47
  public void deleteByTempRepresentation_RetrievedFrom(GitDetails retrievedFrom) {
48
    final Query<?> query =
1✔
49
        entityManager
50
            .createNativeQuery(QUERY_DELETE_BY_RETRIEVED_FROM, QueuedWorkflow.class)
1✔
51
            .unwrap(Query.class);
1✔
52

53
    if (query != null) {
1✔
54
      query.setParameter("retrievedFrom", retrievedFrom, new JsonType(GitDetails.class));
1✔
55
      query.executeUpdate();
1✔
56
    }
57
  }
1✔
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc