Commit d0cc8caf authored by 0Tyler's avatar 0Tyler

getPrivacyPolicyChoices function change

parent 3cae3858
This diff is collapsed.
......@@ -34,11 +34,13 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation "org.mapstruct:mapstruct:${mapstructVersion}"
compileOnly 'org.projectlombok:lombok'
implementation "org.mapstruct:mapstruct:${mapstructVersion}"
runtimeOnly 'com.h2database:h2'
runtimeOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}"
testImplementation 'org.springframework.boot:spring-boot-starter-test'
......
......@@ -5,7 +5,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class CloudApplication {
public static void main(String[] args) {
SpringApplication.run(CloudApplication.class, args);
}
......
package edu.prlab.tyler.iotgateway.cloud.pojo.privacy;
import com.fasterxml.jackson.annotation.JsonIgnore;
import edu.prlab.tyler.iotgateway.cloud.pojo.privacy.p3p.Access;
import edu.prlab.tyler.iotgateway.cloud.pojo.privacy.p3p.Collector;
import edu.prlab.tyler.iotgateway.cloud.pojo.privacy.p3p.Dispute;
......
server.port=8081
\ No newline at end of file
server.port=8081
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.h2.console.enabled=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.generate-ddl=true
\ No newline at end of file
......@@ -7,7 +7,6 @@ import org.springframework.boot.autoconfigure.domain.EntityScan;
import javax.persistence.Entity;
@SpringBootApplication
@EntityScan("edu.prlab.tyler.iotgateway")
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
......
......@@ -40,7 +40,7 @@ public class PrivacyService {
}
public Optional<PrivacyChoiceResponse> setPrivacyPolicyChoice(PrivacyChoice privacyChoice) {
System.out.println(privacyChoice.toString());
System.out.println("setPrivacyPolicyChoice : " + privacyChoice.toString());
return Optional.of(privacyChoice)
.map(choice -> template.postForObject(cloudAddress + "/choice", choice, PrivacyChoice.class))
.flatMap(choice -> Optional.of(privacyChoiceIndexRepository.save(PrivacyChoiceIndex.builder()
......@@ -62,13 +62,29 @@ public class PrivacyService {
public Iterable<PrivacyChoiceResponse> getPrivacyPolicyChoices() {
return () -> StreamSupport.stream(
template.exchange(cloudAddress + "/choice", HttpMethod.GET, null,
new ParameterizedTypeReference<Iterable<PrivacyChoice>>() { }).getBody().spliterator(),
new ParameterizedTypeReference<Iterable<PrivacyChoice>>() {
}).getBody().spliterator(),
false)
.map(choice -> privacyChoiceIndexRepository.findById(choice.getId())
.map(choiceIndex -> PrivacyChoiceResponse.builder()
.id(choiceIndex.getId())
.localDateTime(choiceIndex.getLocalDateTime())
.privacyContent(choice.getPrivacyContent())
.build()).get()).iterator();
.build())
.orElseGet(() -> new PrivacyChoiceResponse())
).iterator();
}
// private PrivacyChoiceResponse getPrivacyChoiceResponse(PrivacyChoice choice) {
// return privacyChoiceIndexRepository.findById(choice.getId())
// .map(choiceIndex -> PrivacyChoiceResponse.builder()
// .id(choiceIndex.getId())
// .localDateTime(choiceIndex.getLocalDateTime())
// .privacyContent(choice.getPrivacyContent())
// .build())
// .orElseGet(() -> {
// System.out.println(choice.getId() + "is not found");
// return new PrivacyChoiceResponse();
// });
// }
}
......@@ -123,5 +123,13 @@ public class GatewayHttpApiTest {
.andExpect(status().isOk())
.andReturn();
Assert.assertNotNull(result);
result = mvc.perform(MockMvcRequestBuilders
.get("/choice")
.accept(MediaType.APPLICATION_JSON_UTF8))
.andDo(print())
.andExpect(status().isOk())
.andReturn();
Assert.assertNotNull(result);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment