Compare commits
3 Commits
feature/ge
...
feature/te
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
994db8afad | ||
|
|
dabee5c844 | ||
|
|
24c8039031 |
5
.idea/workspace.xml
generated
5
.idea/workspace.xml
generated
@@ -1,10 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="2a93e153-a90c-44db-b1da-6c4424693422" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/server/src/main/java/com/ticketing/server/global/config/SwaggerConfig.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/server/build.gradle.kts" beforeDir="false" afterPath="$PROJECT_DIR$/server/build.gradle.kts" afterDir="false" />
|
||||
</list>
|
||||
<list default="true" id="2a93e153-a90c-44db-b1da-6c4424693422" name="Changes" comment="" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
java
|
||||
id("org.springframework.boot") version "2.6.7"
|
||||
id("io.spring.dependency-management") version "1.0.11.RELEASE"
|
||||
java
|
||||
id("org.springframework.boot") version "2.6.7"
|
||||
id("io.spring.dependency-management") version "1.0.11.RELEASE"
|
||||
}
|
||||
|
||||
group = "com.ticketing"
|
||||
@@ -9,58 +9,59 @@ version = "0.0.1-SNAPSHOT"
|
||||
|
||||
val javaVersion = JavaVersion.VERSION_11
|
||||
java {
|
||||
sourceCompatibility = javaVersion
|
||||
targetCompatibility = javaVersion
|
||||
sourceCompatibility = javaVersion
|
||||
targetCompatibility = javaVersion
|
||||
}
|
||||
|
||||
configurations {
|
||||
compileOnly {
|
||||
extendsFrom(configurations.annotationProcessor.get())
|
||||
}
|
||||
compileOnly {
|
||||
extendsFrom(configurations.annotationProcessor.get())
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
|
||||
implementation("org.springframework.boot:spring-boot-starter-security")
|
||||
implementation("org.springframework.boot:spring-boot-starter-validation")
|
||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||
implementation("org.springframework.boot:spring-boot-starter-actuator")
|
||||
implementation("org.springframework.boot:spring-boot-starter-log4j2")
|
||||
implementation("org.projectlombok:lombok:1.18.20")
|
||||
implementation("io.springfox:springfox-swagger2:3.0.0")
|
||||
implementation("io.springfox:springfox-swagger-ui:3.0.0")
|
||||
implementation("com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.4")
|
||||
implementation("com.lmax:disruptor:3.4.2")
|
||||
implementation("io.jsonwebtoken:jjwt-api:0.11.2")
|
||||
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
|
||||
implementation("org.springframework.boot:spring-boot-starter-security")
|
||||
implementation("org.springframework.boot:spring-boot-starter-validation")
|
||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||
implementation("org.springframework.boot:spring-boot-starter-actuator")
|
||||
implementation("org.springframework.boot:spring-boot-starter-log4j2")
|
||||
implementation("org.projectlombok:lombok:1.18.20")
|
||||
implementation("io.springfox:springfox-swagger2:3.0.0")
|
||||
implementation("io.springfox:springfox-swagger-ui:3.0.0")
|
||||
implementation("com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.4")
|
||||
implementation("com.lmax:disruptor:3.4.2")
|
||||
implementation("io.jsonwebtoken:jjwt-api:0.11.2")
|
||||
implementation("com.googlecode.json-simple:json-simple:1.1.1")
|
||||
|
||||
modules {
|
||||
module("org.springframework.boot:spring-boot-starter-logging") {
|
||||
replacedBy("org.springframework.boot:spring-boot-starter-log4j2", "Use Log4j2 instead of Logback")
|
||||
}
|
||||
}
|
||||
modules {
|
||||
module("org.springframework.boot:spring-boot-starter-logging") {
|
||||
replacedBy("org.springframework.boot:spring-boot-starter-log4j2", "Use Log4j2 instead of Logback")
|
||||
}
|
||||
}
|
||||
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.springframework.security:spring-security-test")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.springframework.security:spring-security-test")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
|
||||
|
||||
compileOnly("org.projectlombok:lombok")
|
||||
runtimeOnly("mysql:mysql-connector-java")
|
||||
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.2")
|
||||
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.2")
|
||||
annotationProcessor("org.projectlombok:lombok")
|
||||
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
|
||||
compileOnly("org.projectlombok:lombok")
|
||||
runtimeOnly("mysql:mysql-connector-java")
|
||||
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.2")
|
||||
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.2")
|
||||
annotationProcessor("org.projectlombok:lombok")
|
||||
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
|
||||
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.springframework.security:spring-security-test")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.springframework.security:spring-security-test")
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
useJUnitPlatform()
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.ticketing.server.global.config;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.time.Duration;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.BufferingClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Configuration
|
||||
public class RestTemplateConfig {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
|
||||
return restTemplateBuilder
|
||||
.requestFactory(() -> new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()))
|
||||
.setConnectTimeout(Duration.ofMillis(5000)) // connection-timeout
|
||||
.setReadTimeout(Duration.ofMillis(5000)) // read-timeout
|
||||
.additionalMessageConverters(new StringHttpMessageConverter(Charset.forName("UTF-8")))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.ticketing.server.movie.service;
|
||||
|
||||
import com.ticketing.server.movie.service.interfaces.TMDBService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TMBDServiceImpl implements TMDBService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.ticketing.server.movie.service.interfaces;
|
||||
|
||||
public interface TMDBService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.ticketing.server.movie.service;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@SpringBootTest
|
||||
public class TMDBServiceImplTest {
|
||||
|
||||
@Value("${tmdb.api-key}")
|
||||
private String apiKey;
|
||||
|
||||
@Value("${tmdb.read-access-token}")
|
||||
private String readAccessToken;
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
|
||||
@Test
|
||||
@DisplayName("TMDB Service Test - Get [Now Playing] movies")
|
||||
void shouldAbleToGetMovieList() throws Exception {
|
||||
// given
|
||||
assertNotNull(apiKey);
|
||||
assertNotNull(readAccessToken);
|
||||
|
||||
ArrayList<Charset> acceptCharset = new ArrayList<>();
|
||||
acceptCharset.add(StandardCharsets.UTF_8);
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAcceptCharset(acceptCharset);
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.setBearerAuth(readAccessToken);
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("api_key", apiKey);
|
||||
params.put("language", "ko");
|
||||
|
||||
HttpEntity<?> request = new HttpEntity<>(headers);
|
||||
|
||||
// when
|
||||
ResponseEntity<?> response = restTemplate.exchange(
|
||||
"https://api.themoviedb.org/3/movie/now_playing?" + mapToUrlParam(params),
|
||||
HttpMethod.GET,
|
||||
request,
|
||||
String.class
|
||||
);
|
||||
|
||||
// JSONParser parser = new JSONParser();
|
||||
// Object obj = parser.parse(String.valueOf(response));
|
||||
// Object results = ((JSONObject) obj).get("results");
|
||||
//
|
||||
// ArrayList<String> movieList = new ArrayList<>();
|
||||
//
|
||||
// ArrayList<JSONObject> jsonMovieList = new ArrayList<>();
|
||||
|
||||
// then
|
||||
assertTrue(response.getStatusCode().is2xxSuccessful());
|
||||
}
|
||||
|
||||
private static String mapToUrlParam(Map<String, String> params) {
|
||||
StringBuffer paramData = new StringBuffer();
|
||||
|
||||
for (Map.Entry<String, String> param : params.entrySet()) {
|
||||
if (paramData.length() != 0) {
|
||||
paramData.append('&');
|
||||
}
|
||||
|
||||
paramData.append(param.getKey());
|
||||
paramData.append('=');
|
||||
paramData.append(param.getValue());
|
||||
}
|
||||
|
||||
return paramData.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,3 +22,8 @@ jwt:
|
||||
prefix: Bearer
|
||||
secret-key: Zi1sYWItdGlja2V0aW5nLXByb2plY3Qtc3ByaW5nLWJvb3Qtc2VjdXJpdHktand0LXNlY3JldC1rZXktZi1sYWItdGlja2V0aW5nLXByb2plY3Qtc3ByaW5nLWJvb3Qtc2VjdXJpdHktand0LXNlY3JldC1rZXkK
|
||||
token-validity-in-seconds: 86400
|
||||
|
||||
tmdb:
|
||||
api-key: 0d1503b6dcbfe1c514299b5564c649b8
|
||||
read-access-token: eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIwZDE1MDNiNmRjYmZlMWM1MTQyOTliNTU2NGM2NDliOCIsInN1YiI6IjYyOWYwODRlNzI2ZmIxMTA2NDA4MjI2NCIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.rs8KZea8QLyashILiggWFx2s46lgUtzo-xSWoDgE58A
|
||||
|
||||
|
||||
Reference in New Issue
Block a user