Skip to content

Commit

Permalink
SPARK-28067: Enhancement for test framework - use more human readable…
Browse files Browse the repository at this point in the history
… test data instead of UUIDs
  • Loading branch information
alewir authored and alewir committed Nov 3, 2020
1 parent 174d072 commit b0019c4
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 24 deletions.
24 changes: 12 additions & 12 deletions LICENSE-THIRD-PARTY.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Lists of 150 third-party dependencies.
Lists of 151 third-party dependencies.
(Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Classic Module (ch.qos.logback:logback-classic:1.2.3 - http://logback.qos.ch/logback-classic)
(Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Core Module (ch.qos.logback:logback-core:1.2.3 - http://logback.qos.ch/logback-core)
(The Apache License, Version 2.0) spock-reports (com.athaydes:spock-reports:1.7.1 - https://github.com/renatoathaydes/spock-reports)
Expand All @@ -12,16 +12,20 @@ Lists of 150 third-party dependencies.
(The Apache Software License, Version 2.0) Jackson datatype: jdk8 (com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.11.2 - https://github.com/FasterXML/jackson-modules-java8/jackson-datatype-jdk8)
(The Apache Software License, Version 2.0) Jackson datatype: JSR310 (com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.2 - https://github.com/FasterXML/jackson-modules-java8/jackson-datatype-jsr310)
(The Apache Software License, Version 2.0) Jackson-module-parameter-names (com.fasterxml.jackson.module:jackson-module-parameter-names:2.11.2 - https://github.com/FasterXML/jackson-modules-java8/jackson-module-parameter-names)
(The Apache Software License, Version 2.0) docker-java-api (com.github.docker-java:docker-java-api:3.2.5 - https://github.com/docker-java/docker-java)
(The Apache Software License, Version 2.0) docker-java-transport (com.github.docker-java:docker-java-transport:3.2.5 - https://github.com/docker-java/docker-java)
(The Apache Software License, Version 2.0) docker-java-transport-zerodep (com.github.docker-java:docker-java-transport-zerodep:3.2.5 - https://github.com/docker-java/docker-java)
(The Apache Software License, Version 2.0) Java Faker (com.github.javafaker:javafaker:1.0.2 - http://github.com/DiUS/java-faker)
(The Apache Software License, Version 2.0) Generex (com.github.mifmif:generex:1.0.2 - https://github.com/mifmif/Generex/tree/master)
(The Apache Software License, Version 2.0) project ':json-path' (com.jayway.jsonpath:json-path:2.4.0 - https://github.com/jayway/JsonPath)
(Apache License, Version 2.0) junixsocket-common (com.kohlschutter.junixsocket:junixsocket-common:2.0.4 - https://github.com/kohlschutter/junixsocket/junixsocket-common)
(Apache License, Version 2.0) junixsocket-native-common (com.kohlschutter.junixsocket:junixsocket-native-common:2.0.4 - https://github.com/kohlschutter/junixsocket/junixsocket-native-common)
(Apache License, Version 2.0) appstore-metadata-service (com.lgi.appstore.metadata:appstore-metadata-service:0.0.1-SNAPSHOT - https://spring.io/projects/spring-boot/appstore-metadata-service-parent/appstore-metadata-service)
(Apache License 2.0) JSON library from Android SDK (com.vaadin.external.google:android-json:0.0.20131108.vaadin1 - http://developer.android.com/sdk)
(The Apache Software License, Version 2.0) HikariCP (com.zaxxer:HikariCP:3.4.5 - https://github.com/brettwooldridge/HikariCP)
(Apache License, Version 2.0) Apache Commons BeanUtils (commons-beanutils:commons-beanutils:1.9.4 - https://commons.apache.org/proper/commons-beanutils/)
(Apache License, Version 2.0) Apache Commons Codec (commons-codec:commons-codec:1.14 - https://commons.apache.org/proper/commons-codec/)
(Apache License, Version 2.0) Apache Commons Collections (commons-collections:commons-collections:3.2.2 - http://commons.apache.org/collections/)
(The Apache Software License, Version 2.0) Apache Commons Logging (commons-logging:commons-logging:1.2 - http://commons.apache.org/proper/commons-logging/)
(BSD) Automaton (dk.brics.automaton:automaton:1.11-8 - http://www.brics.dk/automaton/)
(The MIT License (MIT)) ClassGraph (io.github.classgraph:classgraph:4.8.69 - https://github.com/classgraph/classgraph)
(The Apache Software License, Version 2.0) micrometer-core (io.micrometer:micrometer-core:1.5.5 - https://github.com/micrometer-metrics/micrometer)
(The Apache Software License, Version 2.0) Allure Attachments (io.qameta.allure:allure-attachments:2.13.6 - https://github.com/allure-framework/allure-java)
Expand All @@ -48,8 +52,7 @@ Lists of 150 third-party dependencies.
(Eclipse Public License 1.0) JUnit (junit:junit:4.13 - http://junit.org)
(Apache License, Version 2.0) Byte Buddy (without dependencies) (net.bytebuddy:byte-buddy:1.10.14 - https://bytebuddy.net/byte-buddy)
(Apache License, Version 2.0) Byte Buddy agent (net.bytebuddy:byte-buddy-agent:1.10.14 - https://bytebuddy.net/byte-buddy-agent)
(Apache License v2.0) (LGPL, version 2.1) Java Native Access (net.java.dev.jna:jna:5.5.0 - https://github.com/java-native-access/jna)
(Apache License v2.0) (LGPL, version 2.1) Java Native Access Platform (net.java.dev.jna:jna-platform:5.5.0 - https://github.com/java-native-access/jna)
(Apache License v2.0) (LGPL, version 2.1) Java Native Access (net.java.dev.jna:jna:5.2.0 - https://github.com/java-native-access/jna)
(The Apache Software License, Version 2.0) ASM based accessors helper used by json-smart (net.minidev:accessors-smart:1.2 - http://www.minidev.net/)
(The Apache Software License, Version 2.0) JSON Small and Fast Parser (net.minidev:json-smart:2.3 - http://www.minidev.net/)
(Apache License, Version 2.0) Apache Commons Compress (org.apache.commons:commons-compress:1.20 - https://commons.apache.org/proper/commons-compress/)
Expand Down Expand Up @@ -84,7 +87,6 @@ Lists of 150 third-party dependencies.
(BSD-2-Clause) (Public Domain, per Creative Commons CC0) HdrHistogram (org.hdrhistogram:HdrHistogram:2.1.12 - http://hdrhistogram.github.io/HdrHistogram/)
(Apache License 2.0) Hibernate Validator Engine (org.hibernate.validator:hibernate-validator:6.1.5.Final - http://hibernate.org/validator/hibernate-validator)
(Apache License, version 2.0) JBoss Logging 3 (org.jboss.logging:jboss-logging:3.4.1.Final - http://www.jboss.org)
(The Apache Software License, Version 2.0) JetBrains Java Annotations (org.jetbrains:annotations:19.0.0 - https://github.com/JetBrains/java-annotations)
(Apache License, Version 2.0) jOOQ (org.jooq:jooq:3.13.4 - http://www.jooq.org/jooq)
(Apache License, Version 2.0) jOOR (org.jooq:joor-java-8:0.9.13 - https://github.com/jOOQ/jOOR)
(Eclipse Public License v2.0) JUnit Jupiter (Aggregator) (org.junit.jupiter:junit-jupiter:5.6.2 - https://junit.org/junit5/)
Expand All @@ -102,10 +104,8 @@ Lists of 150 third-party dependencies.
(BSD) ASM Core (org.ow2.asm:asm:5.0.4 - http://asm.objectweb.org/asm/)
(BSD-2-Clause) PostgreSQL JDBC Driver (org.postgresql:postgresql:42.2.16 - https://jdbc.postgresql.org)
(CC0) reactive-streams (org.reactivestreams:reactive-streams:1.0.3 - http://www.reactive-streams.org/)
(MIT) TCP to Unix Socket Proxy (org.rnorth:tcp-unix-socket-proxy:1.0.2 - https://github.com/rnorth/tcp-unix-socket-proxy)
(MIT) Duct Tape (org.rnorth.duct-tape:duct-tape:1.0.8 - https://github.com/rnorth/duct-tape)
(MIT) Visible Assertions (org.rnorth.visible-assertions:visible-assertions:2.1.2 - https://github.com/rnorth/visible-assertions)
(CC0 1.0 Universal License) Native Library Loader (org.scijava:native-lib-loader:2.0.2 - http://github.com/scijava/native-lib-loader)
(The Apache Software License, Version 2.0) JSONassert (org.skyscreamer:jsonassert:1.5.0 - https://github.com/skyscreamer/JSONassert)
(MIT License) JUL to SLF4J bridge (org.slf4j:jul-to-slf4j:1.7.30 - http://www.slf4j.org)
(MIT License) SLF4J API Module (org.slf4j:slf4j-api:1.7.30 - http://www.slf4j.org)
Expand Down Expand Up @@ -142,10 +142,10 @@ Lists of 150 third-party dependencies.
(Apache License, Version 2.0) spring-boot-starter-web (org.springframework.boot:spring-boot-starter-web:2.3.4.RELEASE - https://spring.io/projects/spring-boot)
(Apache License, Version 2.0) spring-boot-test (org.springframework.boot:spring-boot-test:2.3.4.RELEASE - https://spring.io/projects/spring-boot)
(Apache License, Version 2.0) spring-boot-test-autoconfigure (org.springframework.boot:spring-boot-test-autoconfigure:2.3.4.RELEASE - https://spring.io/projects/spring-boot)
(MIT) Testcontainers :: Database-Commons (org.testcontainers:database-commons:1.14.3 - https://testcontainers.org)
(MIT) Testcontainers :: JDBC (org.testcontainers:jdbc:1.14.3 - https://testcontainers.org)
(MIT) Testcontainers :: JDBC :: PostgreSQL (org.testcontainers:postgresql:1.14.3 - https://testcontainers.org)
(MIT) Testcontainers Core (org.testcontainers:testcontainers:1.14.3 - https://testcontainers.org)
(MIT) Testcontainers :: Database-Commons (org.testcontainers:database-commons:1.15.0-rc2 - https://testcontainers.org)
(MIT) Testcontainers :: JDBC (org.testcontainers:jdbc:1.15.0-rc2 - https://testcontainers.org)
(MIT) Testcontainers :: JDBC :: PostgreSQL (org.testcontainers:postgresql:1.15.0-rc2 - https://testcontainers.org)
(MIT) Testcontainers Core (org.testcontainers:testcontainers:1.15.0-rc2 - https://testcontainers.org)
(Apache 2.0) Swagger UI (org.webjars:swagger-ui:3.28.0 - http://webjars.org)
(MIT) webjars-locator-core (org.webjars:webjars-locator-core:0.45 - http://webjars.org)
(The Apache Software License, Version 2.0) org.xmlunit:xmlunit-core (org.xmlunit:xmlunit-core:2.7.0 - https://www.xmlunit.org/)
Expand Down
6 changes: 6 additions & 0 deletions appstore-metadata-service-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@
<version>${groovy-version}</version>
<type>pom</type>
</dependency>

<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package com.lgi.appstore.metadata.api.testing.functional.framework.model.request;

import com.lgi.appstore.metadata.api.testing.functional.framework.model.response.ApplicationDetailsPath;
import com.lgi.appstore.metadata.api.testing.functional.framework.utils.DataUtils;
import com.lgi.appstore.metadata.model.Application;
import com.lgi.appstore.metadata.model.ApplicationForUpdate;
import com.lgi.appstore.metadata.model.ApplicationHeaderForUpdate;
Expand All @@ -31,13 +32,11 @@
import com.lgi.appstore.metadata.model.MaintainerApplicationHeader;
import com.lgi.appstore.metadata.model.Platform;
import com.lgi.appstore.metadata.model.Requirements;
import org.jetbrains.annotations.NotNull;
import org.testcontainers.shaded.org.apache.commons.lang.NotImplementedException;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -175,11 +174,12 @@ private ApplicationMetadataBuilder setFieldValue(String field, Object value) {
}

public ApplicationMetadataBuilder fromDefaults() {
this.headerName = String.format("AppName_%s", UUID.randomUUID().toString());
this.headerDescription = String.format("AppDescription_%s", UUID.randomUUID().toString());
this.headerUrl = String.format("AppUrl_%s", UUID.randomUUID().toString());
this.headerType = String.format("AppType_%s", UUID.randomUUID().toString());
this.headerIcon = String.format("AppIcon_%s", UUID.randomUUID().toString());
this.headerName = DataUtils.randomAppName();
this.headerVersion = DataUtils.randomAppVersion();
this.headerDescription = DataUtils.randomAppDescription();
this.headerUrl = DataUtils.randomAppUrl();
this.headerType = DataUtils.randomAppHeaderType();
this.headerIcon = DataUtils.randomAppHeaderIcon();
this.headerVisible = Boolean.TRUE;
this.headerCategory = Category.APPLICATION;

Expand Down Expand Up @@ -242,7 +242,6 @@ public ApplicationForUpdate forUpdate() {
.requirements(Optional.ofNullable(requirements).orElse(assembleRequirements()));
}

@NotNull
private Requirements assembleRequirements() {
Requirements requirements = new Requirements();
Optional.ofNullable(platform).ifPresent(requirements::platform);
Expand Down Expand Up @@ -300,4 +299,4 @@ private Feature newFeature(Feature feature) {
.version(feature.getVersion())
.required(feature.isRequired());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package com.lgi.appstore.metadata.api.testing.functional.framework.utils;

import com.github.javafaker.Faker;
import com.lgi.appstore.metadata.api.testing.functional.framework.model.request.QueryParams;
import com.lgi.appstore.metadata.model.Application;
import com.lgi.appstore.metadata.model.Category;
Expand All @@ -31,16 +32,20 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.Random;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static com.lgi.appstore.metadata.api.testing.functional.framework.model.request.QueryParams.mapping;

/**
* @noinspection WeakerAccess as this is utility class
*/
public class DataUtils {
private static final Random RANDOM = new Random();
private static final Faker FAKER = new Faker();

public static Category pickRandomCategory() {
return pickRandomCategoryExcluding(null);
}
Expand All @@ -56,7 +61,31 @@ public static Category pickRandomCategoryExcluding(Category excludingThisOne) {
}

public static String randId() {
return String.format("appId_%s", UUID.randomUUID());
return randomReversedDomainName();
}

public static String randomAppHeaderIcon() {
return FAKER.avatar().image();
}

public static String randomAppHeaderType() {
return String.format("%s.rdk-app.dac.native", FAKER.file().mimeType());
}

public static String randomAppUrl() {
return FAKER.internet().url();
}

public static String randomAppVersion() {
return FAKER.app().version();
}

public static String randomAppName() {
return FAKER.app().name();
}

public static String randomAppDescription() {
return String.format("All rights reserved by %s", FAKER.app().author());
}

public static String getFieldValueFromApplication(String field, Application app, Map<Application, String> maintainerNamesForApps) {
Expand Down Expand Up @@ -102,4 +131,12 @@ public static String platformQueryString(Application app) {
var platformProperties = List.of(platform.getArchitecture(), platform.getVariant(), platform.getOs());
return String.join(":", platformProperties.subList(0, RandomUtils.nextInt(1, platformProperties.size()))); // architecture is mandatory
}

private static String randomReversedDomainName() {
int domainFirstWordIdx = 1;
int domainMaxWords = 2 + RANDOM.nextInt(3); // min 2, max 5
return FAKER.internet().domainSuffix() + "." + IntStream.range(domainFirstWordIdx, domainMaxWords).boxed()
.map(i -> FAKER.internet().domainWord())
.collect(Collectors.joining("."));
}
}
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>1.14.3</version>
<!--due to https://github.com/testcontainers/testcontainers-java/pull/3159-->
<version>1.15.0-rc2</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand Down

0 comments on commit b0019c4

Please sign in to comment.