Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Lang
jsonparser
Commits
d44b20c9
Commit
d44b20c9
authored
Jul 08, 2021
by
Andreas Heilemann
Browse files
[1] add maven and add tests
parent
70a7a319
Changes
5
Hide whitespace changes
Inline
Side-by-side
.gitignore
0 → 100755
View file @
d44b20c9
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
pom.xml
0 → 100755
View file @
d44b20c9
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.5.2
</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>
de.thd
</groupId>
<artifactId>
jsonparser
</artifactId>
<version>
1.0.0-SNAPSHOT
</version>
<name>
jsonparser
</name>
<description>
Coding challenge for new hires
</description>
<properties>
<java.version>
11
</java.version>
</properties>
<dependencies>
<!-- TODO Add here dependency to your preferred JSON parser framework -->
<dependency>
<groupId>
org.junit.jupiter
</groupId>
<artifactId>
junit-jupiter
</artifactId>
<version>
5.7.2
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.assertj
</groupId>
<artifactId>
assertj-core
</artifactId>
<version>
3.19.0
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-jar-plugin
</artifactId>
<version>
3.2.0
</version>
</plugin>
</plugins>
</build>
</project>
src/main/java/de/thd/jsonparser/JsonparserApplication.java
0 → 100755
View file @
d44b20c9
package
de.thd.jsonparser
;
import
java.util.Collections
;
import
java.util.List
;
public
class
JsonparserApplication
{
public
JsonparserApplication
(
String
jsonContent
)
{
// TODO
}
public
String
getLeadDisplayName
()
{
// TODO
return
"TODO"
;
}
public
List
<
String
>
getAllIssueTypeIdsWhereNameStartsWith
(
String
prefix
)
{
// TODO
return
Collections
.
singletonList
(
"TODO"
);
}
public
List
<
String
>
getComponents
()
{
// TODO
return
null
;
}
}
src/test/java/de/thd/jsonparser/JsonparserApplicationTests.java
0 → 100755
View file @
d44b20c9
package
de.thd.jsonparser
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.util.List
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
class
JsonparserApplicationTests
{
JsonparserApplication
sut
;
// service under test
@BeforeEach
void
setup
()
throws
IOException
,
URISyntaxException
{
URL
url
=
Thread
.
currentThread
().
getContextClassLoader
().
getResource
(
"input.json"
);
final
String
content
=
Files
.
readString
(
Path
.
of
(
url
.
toURI
()),
StandardCharsets
.
UTF_8
);
sut
=
new
JsonparserApplication
(
content
);
}
@Test
void
testGetLeadDisplayName
()
{
String
actual
=
sut
.
getLeadDisplayName
();
assertThat
(
actual
).
isEqualTo
(
"Max Mustermann"
);
}
@Test
void
testGetAllIssueTypeIdsWhereNameStartsWith
()
{
List
<
String
>
actual
=
sut
.
getAllIssueTypeIdsWhereNameStartsWith
(
"Vertrag"
);
assertThat
(
actual
).
contains
(
"10807"
);
assertThat
(
actual
.
size
()).
isEqualTo
(
2
);
assertThat
(
actual
).
contains
(
"10808"
);
}
@Test
void
noComponents
()
{
var
actual
=
sut
.
getComponents
();
assertThat
(
actual
).
isEmpty
();
}
}
input.json
→
src/test/resources/
input.json
View file @
d44b20c9
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment