Skip to content

Commit

Permalink
removed spring oauth dependency, updated testmode controller
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlehansen committed Oct 21, 2018
1 parent 17e5129 commit 68ef124
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ repositories {


dependencies {
compile('no.fint:fint-sse:1.1.4-rc-2')
compile('no.fint:fint-sse:1.1.4-rc-2') {
exclude group: 'org.springframework.security.oauth', module: 'spring-security-oauth2'
}
compile('org.glassfish.jersey.core:jersey-client:2.26')
compile('org.glassfish.jersey.core:jersey-common:2.26')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package no.fint.provider.events.testMode.consumer;


import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j;
import no.fint.event.model.Event;
import no.fint.events.FintEventListener;
import no.fint.events.FintEvents;
import no.fint.provider.events.testMode.TestModeConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Slf4j
@ConditionalOnProperty(name = "fint.provider.test-mode", havingValue = "true")
Expand All @@ -24,20 +27,35 @@ public class TestModeController implements FintEventListener {
@Autowired
private FintEvents fintEvents;

private List<Event> receivedEvents = Collections.synchronizedList(new ArrayList<>());

@PostConstruct
public void init() {
fintEvents.registerUpstreamListener(TestModeConstants.ORGID, this);
}

@PostMapping
public void sendEvent(@RequestParam(defaultValue = "1", required = false) Integer numberOfEvents) {
for(int i = 0; i < numberOfEvents; i++) {
Event<String> event = new Event<>(TestModeConstants.ORGID, TestModeConstants.SOURCE, TestModeConstants.ACTION, TestModeConstants.CLIENT);
fintEvents.sendDownstream(event);
}
}

@GetMapping
public ResponseEntity get() {
Event<String> event = new Event<>(TestModeConstants.ORGID, TestModeConstants.SOURCE, "GET", TestModeConstants.CLIENT);
fintEvents.sendDownstream(event);
return ResponseEntity.ok().build();
public List<Map<String, String>> getReceivedEvents() {
return receivedEvents.stream().map(event ->
ImmutableMap.of(
"corrId", event.getCorrId(),
"status", event.getStatus().name(),
"data", event.getData().get(0).toString()
)
).collect(Collectors.toList());
}

@Override
public void accept(Event event) {
log.info("Received event: {}", event.getData());
receivedEvents.add(event);
}
}
4 changes: 0 additions & 4 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@ server:

fint:
version: '@version@'

security:
basic:
enabled: false

0 comments on commit 68ef124

Please sign in to comment.