forked from thoughtworks/HeartBeat
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADM-709:[backend][docs]:Verify buildkite and obtain buildkite data wi…
…th new API (#889) * ADM-709:[backend]feat: add verify token and get info for buildKite controller Co-authored-by: Andrea <Andrea2000728>
- Loading branch information
1 parent
ca482f0
commit 54df641
Showing
8 changed files
with
425 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
backend/src/main/java/heartbeat/controller/pipeline/dto/request/PipelineType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package heartbeat.controller.pipeline.dto.request; | ||
|
||
import lombok.extern.log4j.Log4j2; | ||
|
||
@Log4j2 | ||
public enum PipelineType { | ||
|
||
BUILDKITE("buildkite"); | ||
|
||
public final String pipelineType; | ||
|
||
PipelineType(String pipelineType) { | ||
this.pipelineType = pipelineType; | ||
} | ||
|
||
public static PipelineType fromValue(String type) { | ||
return switch (type) { | ||
case "buildkite" -> BUILDKITE; | ||
default -> { | ||
log.error("Failed to match Pipeline type: {} ", type); | ||
throw new IllegalArgumentException("Pipeline type does not find!"); | ||
} | ||
}; | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
backend/src/main/java/heartbeat/controller/pipeline/dto/request/TokenParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package heartbeat.controller.pipeline.dto.request; | ||
|
||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class TokenParam { | ||
|
||
@Valid | ||
@NotBlank(message = "Token cannot be empty.") | ||
private String token; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
backend/src/test/java/heartbeat/controller/pipeline/dto/response/PipelineTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package heartbeat.controller.pipeline.dto.response; | ||
|
||
import heartbeat.controller.pipeline.dto.request.PipelineType; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class PipelineTypeTest { | ||
|
||
@Test | ||
public void shouldConvertValueToType() { | ||
PipelineType buildKiteType = PipelineType.fromValue("buildkite"); | ||
|
||
assertEquals(buildKiteType, PipelineType.BUILDKITE); | ||
} | ||
|
||
@Test | ||
public void shouldThrowExceptionWhenDateTypeNotSupported() { | ||
assertThatThrownBy(() -> PipelineType.fromValue("unknown")).isInstanceOf(IllegalArgumentException.class) | ||
.hasMessageContaining("Pipeline type does not find!"); | ||
} | ||
|
||
} |
Oops, something went wrong.