# Resolving workflow interface(s) based on workflow implementation class

**URL:** <https://community.temporal.io/t/resolving-workflow-interface-s-based-on-workflow-implementation-class/1451>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [February 6, 2021, 12:02am UTC](https://community.temporal.io/t/resolving-workflow-interface-s-based-on-workflow-implementation-class/1451 "2021-02-06T00:02:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GreyTeardrop](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/greyteardrop/32/623_2.png) [@GreyTeardrop](https://community.temporal.io/u/GreyTeardrop)\
**Post date:** [February 6, 2021, 12:02am UTC](https://community.temporal.io/t/resolving-workflow-interface-s-based-on-workflow-implementation-class/1451/1 "2021-02-06T00:02:38Z")

</div>

Hi Temporal team!

I was recently looking into building JUnit 5 extension for Temporal, similarly to the existing `TestWorkflowRule` for JUnit 4.

One of the cool features JUnit 5 provides is parameter resolvers - with it should be possible to automatically inject preconfigured workflow stubs into test class and methods. That requires the extension to have the list of workflow interfaces, however, it gets workflow implementation classes as input, so I’m looking for a way to resolve the workflow implementation class into workflow interface(s) it implements.

Looking through the SDK code, it seems that `POJOWorkflowImplMetadata` and `POJOWorkflowMethodMetadata` encapsulate all the logic required to do that, but they are package private.

How stable are those classes’ APIs? Would you consider opening them up?

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [February 6, 2021, 1:15am UTC](https://community.temporal.io/t/resolving-workflow-interface-s-based-on-workflow-implementation-class/1451/2 "2021-02-06T01:15:53Z")

</div>

Would you explain in more detail about “automatically inject preconfigured workflow stubs into test class and methods.”? I’m not sure what exact problem it solves that TestWorkflowEnvironment already doesn’t.

---

<div class="post-metadata">

**Author:** ![GreyTeardrop](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/greyteardrop/32/623_2.png) [@GreyTeardrop](https://community.temporal.io/u/GreyTeardrop)\
**Post date:** [February 6, 2021, 6:46am UTC](https://community.temporal.io/t/resolving-workflow-interface-s-based-on-workflow-implementation-class/1451/3 "2021-02-06T06:46:33Z")

</div>

It should give a slight convenience by reducing some boilerplate. If we take some JUnit 4 test that uses `TestWorkflowRule` as an example

```java
public class HelloWorkflowTest {

  @Rule
  public TestWorkflowRule testWorkflowRule =
      TestWorkflowRule.newBuilder()
          .setWorkflowTypes(HelloWorkflowImpl.class)
          // the rest of rule setup

  @Test
  public void verifyHelloWorkflow() {
    String taskQueue = testWorkflowRule.getTaskQueue();
    HelloWorkflow workflow =
        testWorkflowRule
            .getWorkflowClient()
            .newWorkflowStub(
                HelloWorkflow.class, WorkflowOptions.newBuilder().setTaskQueue(taskQueue).build());
    // test code goes here
  }
}

```

then with the JUnit 5 extension, the same test might look like

```java
public class HelloWorkflowTest {

  @RegisterExtension
  public TestWorkflowExtension testWorkflowExtension =
      TestWorkflowExtension.newBuilder()
          .setWorkflowTypes(HelloWorkflowImpl.class)
          // the rest of extension setup

  @Test
  // extension injects HelloWorkflow stub, configured with proper task queue
  public void verifyHelloWorkflow(HelloWorkflow workflow) {
    // test code goes here
  }
}

```

---

<div class="post-metadata">

**Author:** ![GreyTeardrop](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/greyteardrop/32/623_2.png) [@GreyTeardrop](https://community.temporal.io/u/GreyTeardrop)\
**Post date:** [February 7, 2021, 5:50pm UTC](https://community.temporal.io/t/resolving-workflow-interface-s-based-on-workflow-implementation-class/1451/4 "2021-02-07T17:50:49Z")

</div>

@maxim Just to clarify: I’ve prototyped this JUnit 5 extension. However, in order for the extension to be able to go from the `HelloWorkflowImpl` class it gets as input to the `HelloWorkflow` interface it has to inject into the test method, I had to make some modifications to `POJOWorkflowImplMetadata` and `POJOWorkflowMethodMetadata` and make them public. I wonder if that might be something you could consider as a contribution, or should I take some other path?

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [February 7, 2021, 6:37pm UTC](https://community.temporal.io/t/resolving-workflow-interface-s-based-on-workflow-implementation-class/1451/5 "2021-02-07T18:37:46Z")

</div>

I’m working on opening up POJOWorkflowImplMetadata. I will submit PR later today.

---

<div class="post-metadata">

**Author:** ![GreyTeardrop](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/greyteardrop/32/623_2.png) [@GreyTeardrop](https://community.temporal.io/u/GreyTeardrop)\
**Post date:** [February 7, 2021, 6:38pm UTC](https://community.temporal.io/t/resolving-workflow-interface-s-based-on-workflow-implementation-class/1451/6 "2021-02-07T18:38:43Z")

</div>

Awesome, thank you!
