Skip to content

Commit

Permalink
Maintenance: #178 remove old code plus update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fjlopez committed Apr 20, 2024
1 parent 63d849e commit f5047cb
Show file tree
Hide file tree
Showing 138 changed files with 818 additions and 1,543 deletions.
2 changes: 1 addition & 1 deletion cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ tasks.register('exportSchemas') {

jacocoTestReport {
reports {
xml.enabled true
xml.required.set(true)
}
}

Expand Down
15 changes: 9 additions & 6 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-actuator'

implementation 'org.springframework.ldap:spring-ldap-core'
implementation 'org.springframework.security:spring-security-ldap'
testImplementation 'com.unboundid:unboundid-ldapsdk'
Expand All @@ -31,18 +32,20 @@ dependencies {
implementation platform("com.squareup.okhttp3:okhttp-bom:${okhttp_version}")
implementation 'com.squareup.okhttp3:okhttp'
implementation 'com.squareup.okhttp3:logging-interceptor'

implementation "org.json:json:${json_version}"
implementation "io.jsonwebtoken:jjwt-api:${jjwt_version}"
implementation "org.springdoc:springdoc-openapi-common:${springdoc_openapi_version}"
implementation "org.springdoc:springdoc-openapi-ui:${springdoc_openapi_version}"
implementation "org.mapstruct:mapstruct:${mapstruct_version}"
implementation "org.apache.commons:commons-lang3:${commons_lang3_version}"

implementation "io.jsonwebtoken:jjwt-impl:${jjwt_version}"
implementation "io.jsonwebtoken:jjwt-jackson:${jjwt_version}"

implementation "org.springdoc:springdoc-openapi-common:${springdoc_openapi_version}"
implementation "org.springdoc:springdoc-openapi-ui:${springdoc_openapi_version}"

implementation "org.mapstruct:mapstruct:${mapstruct_version}"
annotationProcessor "org.mapstruct:mapstruct-processor:${mapstruct_version}"

implementation "org.apache.commons:commons-lang3:${commons_lang3_version}"

testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'com.vaadin.external.google', module: 'android-json'
}
Expand All @@ -54,7 +57,7 @@ compileJava.inputs.files(processResources)

jacocoTestReport {
reports {
xml.enabled true
xml.required.set(true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void configureValidatingRepositoryEventListener(ValidatingRepositoryEvent
}

@Override
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry corsRegistry) {
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) {
config.setReturnBodyForPutAndPost(true);
config.setBasePath("/api");
config.exposeIdsFor(entityManager.getMetamodel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public DatabaseConnectionController(DatabaseConnectionRepository repository, Dat
* @return 200 if valid
*/
@GetMapping("/connections/{id}/test")
public @ResponseBody
@ResponseBody
public
ResponseEntity<String> testConnection(@PathVariable("id") Integer id) {
Optional<DatabaseConnection> connectionOp = repository.findById(id);
if (connectionOp.isPresent()) {
Expand All @@ -60,7 +61,8 @@ ResponseEntity<String> testConnection(@PathVariable("id") Integer id) {
* @return 200 if valid
*/
@PostMapping("/connections/test")
public @ResponseBody
@ResponseBody
public
ResponseEntity<String> testConnection(@NotNull @RequestBody DatabaseConnection connection) {
service.testDriver(connection);
service.testConnection(connection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public FeatureTypeExtractorController(@NonNull List<FeatureTypeExtractor> extrac
* @return 200 if a document is found; client should check this document or 400 if a document cannot be retrieved or the method is not found
*/
@GetMapping("/helpers/feature-type")
public @ResponseBody ResponseEntity<ExtractedMetadata> extractCapabilities(@RequestParam("url") String url) {
@ResponseBody
public ResponseEntity<ExtractedMetadata> extractCapabilities(@RequestParam("url") String url) {
Iterator<FeatureTypeExtractor> iterator = extractors.iterator();
ExtractedMetadata featureType = ExtractedMetadata.builder().success(false).reason("No available extractor").build();
while (iterator.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public ServiceCapabilitiesExtractorController(@NonNull List<ServiceCapabilitiesE
* @return 200 if a document is found; client should check this document or 400 if a document cannot be retrieved or the method is not found
*/
@GetMapping("/helpers/capabilities")
public @ResponseBody
@ResponseBody
public
ResponseEntity<ExtractedMetadata> extractCapabilities(@RequestParam("url") String url) {
Iterator<ServiceCapabilitiesExtractor> iterator = extractors.iterator();
ExtractedMetadata capabilities = ExtractedMetadata.builder().success(false).reason("No available extractor").build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package org.sitmun.administration.service.dashboard;

import com.google.common.collect.Maps;
import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.search.Search;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.groupingBy;
Expand Down Expand Up @@ -45,26 +42,28 @@ private Map<String, Object> collectMetrics() {

private Map<String, Object> hierarchiseMetrics(Map<String, Object> map) {
return map.entrySet().stream()
.map(entry -> Maps.immutableEntry(entry.getKey().split("\\."), entry.getValue()))
.map(entry -> Pair.of(entry.getKey().split("\\."), entry.getValue()))
.collect(groupingBy(entry -> entry.getKey()[0]))
.entrySet().stream()
.map(this::processEntry)
.filter(Objects::nonNull)
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}

private Map.Entry<String, Object> processEntry(Map.Entry<String, List<Map.Entry<String[], Object>>> entry) {
private Map.Entry<String, Object> processEntry(Map.Entry<String, List<Pair<String[], Object>>> entry) {
Object newValue = toValue(entry.getValue().stream()
.map(value -> Maps.immutableEntry(
.map(value -> Pair.of(
Arrays.stream(value.getKey()).skip(1).toArray(String[]::new),
value.getValue())
).collect(toList()));
if (newValue != null) {
return Maps.immutableEntry(entry.getKey(), newValue);
} else return null;
return new AbstractMap.SimpleEntry<>(entry.getKey(), newValue);
} else {
return null;
}
}

private Object toValue(List<Map.Entry<String[], Object>> list) {
private Object toValue(List<Pair<String[], Object>> list) {
if (list.isEmpty()) {
return null;
} else if (list.size() == 1 && list.get(0).getKey().length == 0) {
Expand All @@ -80,15 +79,15 @@ private Object toValue(List<Map.Entry<String[], Object>> list) {
}
}

private Map.Entry<String, Double> processMetric(Meter meter) {
private Pair<String, Double> processMetric(Meter meter) {
if (meter instanceof Gauge) {
Gauge gauge = (Gauge) meter;
String id = gauge.getId().getName().substring(DashboardConfig.METRICS_PREFIX.length());
String suffix = gauge.getId().getTag(TAG);
if (suffix != null) {
id = id + "." + suffix;
id = id + '.' + suffix;
}
return Maps.immutableEntry(id, gauge.value());
return Pair.of(id, gauge.value());
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import lombok.extern.slf4j.Slf4j;
import org.sitmun.domain.database.DatabaseConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.validation.constraints.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ExtractedMetadata extract(String url) {
if (root.isPresent()) {
JSONObject schema = json.getJSONObject(root.get());
String[] qname = root.get().split(":");
String xmlnsKey = "xmlns" + (qname.length == 2 ? ":" + qname[0] : "");
String xmlnsKey = "xmlns" + (qname.length == 2 ? ':' + qname[0] : "");
boolean isXSD = "http://www.w3.org/2001/XMLSchema".equals(schema.optString(xmlnsKey));
if (!isXSD) {
builder.success(false).reason("Not a XML Schema");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package org.sitmun.authentication.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
* DTO object for storing a user's credentials.
*/
@Setter
@Getter
public class UserPasswordAuthenticationRequest {

@Schema(description = "User identifier. It cannot be empty", example = "some_user")
Expand All @@ -19,24 +23,8 @@ public class UserPasswordAuthenticationRequest {
@NotNull
private String password;

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

@Override
public String toString() {
return "LoginDTO{username='" + username + "}";
return "LoginDTO{username='" + username + '}';
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public void addBehavior(Map<String, String> target, PayloadDto payload) {
String sql = datasourcePayloadDto.getSql();
if (sql != null && !sql.isEmpty()) {
if (target.containsKey(SQL_LIMIT)) {
sql = sql + " " + SQL_LIMIT + " " + target.get(SQL_LIMIT);
sql = sql + ' ' + SQL_LIMIT + ' ' + target.get(SQL_LIMIT);
}
if (target.containsKey(SQL_OFFSET)) {
sql = sql + " " + SQL_OFFSET + " " + target.get(SQL_OFFSET);
sql = sql + ' ' + SQL_OFFSET + ' ' + target.get(SQL_OFFSET);
}
datasourcePayloadDto.setSql(sql);
}
Expand Down
Loading

0 comments on commit f5047cb

Please sign in to comment.