Skip to content

Commit

Permalink
refactor: marked obsolete exceptions as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
melistik committed Dec 14, 2023
1 parent 2714bc6 commit 2ede17f
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import io.rocketbase.commons.dto.ErrorResponse;
import lombok.Getter;

/**
* will get later replaced by javax.ws.rs.BadRequestException
*/
@Deprecated
public class BadRequestException extends RuntimeException {

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import io.rocketbase.commons.dto.ErrorResponse;
import lombok.Getter;

/**
* will get later replaced by javax.ws.rs.NotFoundException
*/
@Deprecated
public class NotFoundException extends RuntimeException {

@Getter
Expand Down
6 changes: 0 additions & 6 deletions commons-rest-openapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,5 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.13.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ protected String convertType(String type) {
if ("Integer".equalsIgnoreCase(type) || "Long".equalsIgnoreCase(type) || "Double".equalsIgnoreCase(type) || "Float".equalsIgnoreCase(type) || "Short".equalsIgnoreCase(type) || "BigDecimal".equalsIgnoreCase(type)) {
type = "number";
}
if (type != null && type.endsWith("TSID")) {
return "string";
}
if (type != null && type.endsWith("JsonNode")) {
return "any";
}
for (String java : getJavaToUnknowns()) {
if (java.equalsIgnoreCase(type)) {
return "unknown";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@

import io.rocketbase.commons.openapi.sample.SampleApplication;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;

@Slf4j
@ExtendWith(SpringExtension.class)
Expand All @@ -24,7 +27,15 @@ public class GenerateClientTest {
@Test
public void downloadZip() throws Exception {
File destination = new File("target/test.zip");
FileUtils.copyURLToFile(new URL(baseUrl + "/generator/client/v4/test.zip"), destination);
download(new URL(baseUrl + "/generator/client/v4/test.zip"), destination);
log.info("downloaded: {}", destination.getAbsolutePath());
}

private static void download(URL url, File file) throws IOException {
ReadableByteChannel rbc = Channels.newChannel(url.openStream());
FileOutputStream fos = new FileOutputStream(file);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

import static org.springframework.http.HttpStatus.BAD_REQUEST;

/**
* exception will get later replaced by javax.ws.rs.BadRequestException so that this handler is not needed anymore
*/
@Deprecated
@ControllerAdvice
public class BadRequestExceptionHandler extends BaseExceptionHandler {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

import static org.springframework.http.HttpStatus.NOT_FOUND;

/**
* exception will get later replaced by javax.ws.rs.NotFoundException so that this handler is not needed anymore
*/
@Deprecated
@ControllerAdvice
public class NotFoundExceptionHandler extends BaseExceptionHandler {

Expand Down

0 comments on commit 2ede17f

Please sign in to comment.