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

temporalio / sdk-java / #343

31 Oct 2024 06:31PM UTC coverage: 75.148% (-3.6%) from 78.794%
#343

push

github

web-flow
Fix jacoco coverage (#2304)

5139 of 8240 branches covered (62.37%)

Branch coverage included in aggregate %.

22841 of 28993 relevant lines covered (78.78%)

0.79 hits per line

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

75.68
/temporal-sdk/src/main/java/io/temporal/common/metadata/POJOWorkflowMethodMetadata.java
1
/*
2
 * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
3
 *
4
 * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
 *
6
 * Modifications copyright (C) 2017 Uber Technologies, Inc.
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this material except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *   http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20

21
package io.temporal.common.metadata;
22

23
import java.lang.reflect.Method;
24
import java.util.Objects;
25
import java.util.Optional;
26

27
/** Metadata of a single workflow method. */
28
public final class POJOWorkflowMethodMetadata {
29

30
  private final POJOWorkflowMethod workflowMethod;
31
  private final String name;
32
  private final String description;
33
  private final Class<?> workflowInterface;
34

35
  POJOWorkflowMethodMetadata(POJOWorkflowMethod methodMetadata, Class<?> workflowInterface) {
1✔
36
    this.workflowMethod = Objects.requireNonNull(methodMetadata);
1✔
37
    if (workflowMethod.getType() == WorkflowMethodType.NONE) {
1!
38
      throw new IllegalArgumentException(
×
39
          "Method \""
40
              + methodMetadata.getMethod().getName()
×
41
              + "\" is not annotated with @WorkflowMethod, @SignalMethod @QueryMethod, @UpdateMethod, or @UpdateValidatorMethod");
42
    }
43

44
    this.workflowInterface = Objects.requireNonNull(workflowInterface);
1✔
45
    Optional<String> nameFromAnnotation = workflowMethod.getNameFromAnnotation();
1✔
46
    if (workflowMethod.getType() == WorkflowMethodType.WORKFLOW) {
1✔
47
      this.name = nameFromAnnotation.orElse(workflowInterface.getSimpleName());
1✔
48
    } else {
49
      this.name = nameFromAnnotation.orElse(methodMetadata.getMethod().getName());
1✔
50
    }
51
    this.description = workflowMethod.getDescriptionFromAnnotation().orElse("");
1✔
52
  }
1✔
53

54
  public WorkflowMethodType getType() {
55
    return workflowMethod.getType();
1✔
56
  }
57

58
  /**
59
   * The semantics of the name depends on the value of {@link #getType()}. It is signal name for
60
   * {@link WorkflowMethodType#SIGNAL}, query type for {@link WorkflowMethodType#QUERY} and workflow
61
   * type for {@link WorkflowMethodType#WORKFLOW}.
62
   */
63
  public String getName() {
64
    return name;
1✔
65
  }
66

67
  public String getDescription() {
68
    return description;
1✔
69
  }
70

71
  public Method getWorkflowMethod() {
72
    return workflowMethod.getMethod();
1✔
73
  }
74

75
  public Class<?> getWorkflowInterface() {
76
    return workflowInterface;
1✔
77
  }
78

79
  /** Compare and hash based on method and the interface type only. */
80
  @Override
81
  public boolean equals(Object o) {
82
    if (this == o) return true;
1!
83
    if (o == null || getClass() != o.getClass()) return false;
1!
84
    POJOWorkflowMethodMetadata that = (POJOWorkflowMethodMetadata) o;
1✔
85
    return com.google.common.base.Objects.equal(workflowMethod, that.workflowMethod)
1!
86
        && com.google.common.base.Objects.equal(workflowInterface, that.workflowInterface);
1!
87
  }
88

89
  /** Compare and hash based on method and the interface type only. */
90
  @Override
91
  public int hashCode() {
92
    return com.google.common.base.Objects.hashCode(workflowMethod, workflowInterface);
×
93
  }
94
}
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

© 2025 Coveralls, Inc