Skip to content

Commit 24701f6

Browse files
author
unknown
committed
Codigo fonte Marcio Lamego Teste Desenvolvedor JAVA
1 parent 8be82c7 commit 24701f6

65 files changed

Lines changed: 45441 additions & 71 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.classpath

Lines changed: 167 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
https://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+
20+
import java.io.File;
21+
import java.io.FileInputStream;
22+
import java.io.FileOutputStream;
23+
import java.io.IOException;
24+
import java.net.URL;
25+
import java.nio.channels.Channels;
26+
import java.nio.channels.ReadableByteChannel;
27+
import java.util.Properties;
28+
29+
public class MavenWrapperDownloader {
30+
31+
/**
32+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
33+
*/
34+
private static final String DEFAULT_DOWNLOAD_URL =
35+
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
36+
37+
/**
38+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
39+
* use instead of the default one.
40+
*/
41+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
42+
".mvn/wrapper/maven-wrapper.properties";
43+
44+
/**
45+
* Path where the maven-wrapper.jar will be saved to.
46+
*/
47+
private static final String MAVEN_WRAPPER_JAR_PATH =
48+
".mvn/wrapper/maven-wrapper.jar";
49+
50+
/**
51+
* Name of the property which should be used to override the default download url for the wrapper.
52+
*/
53+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
54+
55+
public static void main(String args[]) {
56+
System.out.println("- Downloader started");
57+
File baseDirectory = new File(args[0]);
58+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
59+
60+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
61+
// wrapperUrl parameter.
62+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
63+
String url = DEFAULT_DOWNLOAD_URL;
64+
if(mavenWrapperPropertyFile.exists()) {
65+
FileInputStream mavenWrapperPropertyFileInputStream = null;
66+
try {
67+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
68+
Properties mavenWrapperProperties = new Properties();
69+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
70+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
71+
} catch (IOException e) {
72+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
73+
} finally {
74+
try {
75+
if(mavenWrapperPropertyFileInputStream != null) {
76+
mavenWrapperPropertyFileInputStream.close();
77+
}
78+
} catch (IOException e) {
79+
// Ignore ...
80+
}
81+
}
82+
}
83+
System.out.println("- Downloading from: : " + url);
84+
85+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
86+
if(!outputFile.getParentFile().exists()) {
87+
if(!outputFile.getParentFile().mkdirs()) {
88+
System.out.println(
89+
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
90+
}
91+
}
92+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
93+
try {
94+
downloadFileFromURL(url, outputFile);
95+
System.out.println("Done");
96+
System.exit(0);
97+
} catch (Throwable e) {
98+
System.out.println("- Error downloading");
99+
e.printStackTrace();
100+
System.exit(1);
101+
}
102+
}
103+
104+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
105+
URL website = new URL(urlString);
106+
ReadableByteChannel rbc;
107+
rbc = Channels.newChannel(website.openStream());
108+
FileOutputStream fos = new FileOutputStream(destination);
109+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
110+
fos.close();
111+
rbc.close();
112+
}
113+
114+
}

.mvn/wrapper/maven-wrapper.jar

47.2 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>springboot</name>
4+
<comment>Demo project for Spring Boot. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
5+
<projects/>
6+
<buildSpec>
7+
<buildCommand>
8+
<name>org.eclipse.jdt.core.javabuilder</name>
9+
</buildCommand>
10+
<buildCommand>
11+
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

HELP.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Getting Started
2+
3+
### Reference Documentation
4+
For further reference, please consider the following sections:
5+
6+
* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
7+
8+
### Guides
9+
The following guides illustrate how to use some features concretely:
10+
11+
* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
12+
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
13+
* [Building REST services with Spring](https://spring.io/guides/tutorials/bookmarks/)
14+
* [Handling Form Submission](https://spring.io/guides/gs/handling-form-submission/)
15+

README.md

Lines changed: 16 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,21 @@
1-
# Show me the code
1+
# TESTE TCS SANTANDER
22

3-
### # DESAFIO:
3+
### Teste Desenvolvedor JAVA Marcio Lamego
4+
Como cenario dado pelo enunciado do teste foi construido a seguinte arquitetura:
45

5-
API REST para Gestão de Gastos!
6+
* Springboot
7+
* Eureka Server / Client - para gerenciar o loadbalance
8+
* JPA - HSQL embbded in memory
9+
* JSON - uma api produzindo JSON para o a funcionaliadde de autocomplete
10+
* Spring MVC
11+
* Spring DATA
12+
* Design Materialize
613

7-
```
8-
Funcionalidade: Integração de gastos por cartão
9-
Apenas sistemas credenciados poderão incluir novos gastos
10-
É esperado um volume de 100.000 inclusões por segundo
11-
Os gastos, serão informados atraves do protoloco JSON, seguindo padrão:
12-
{ "descricao": "alfanumerico", "valor": double americano, "codigousuario": numerico, "data": Data dem formato UTC }
13-
```
14-
```
15-
Funcionalidade: Listagem de gastos*
16-
Dado que acesso como um cliente autenticado que pode visualizar os gastos do cartão
17-
Quando acesso a interface de listagem de gastos
18-
Então gostaria de ver meus gastos mais atuais.
19-
20-
*Para esta funcionalidade é esperado 2.000 acessos por segundo.
21-
*O cliente espera ver gastos realizados a 5 segundos atrás.
22-
```
23-
```
24-
Funcionalidade: Filtro de gastos
25-
Dado que acesso como um cliente autenticado
26-
E acessei a interface de listagem de gastos
27-
E configure o filtro de data igual a 27/03/1992
28-
Então gostaria de ver meus gastos apenas deste dia.
29-
```
30-
```
31-
Funcionalidade: Categorização de gastos
32-
Dado que acesso como um cliente autenticado
33-
Quando acesso o detalhe de um gasto
34-
E este não possui uma categoria
35-
Então devo conseguir incluir uma categoria para este
36-
```
37-
```
38-
Funcionalidade: Sugestão de categoria
39-
Dado que acesso como um cliente autenticado
40-
Quando acesso o detalhe do gasto que não possui categoria
41-
E começo a digitar a categoria que desejo
42-
Então uma lista de sugestões de categoria deve ser exibida, estas baseadas em categorias já informadas por outro usuários.
43-
```
44-
```
45-
Funcionalidade: Categorização automatica de gasto
46-
No processo de integração de gastos, a categoria deve ser incluida automaticamente
47-
caso a descrição de um gasto seja igual a descrição de qualquer outro gasto já categorizado pelo cliente
48-
o mesmo deve receber esta categoria no momento da inclusão do mesmo
49-
```
50-
### # Avaliação
14+
### Guides
15+
Para iniciar a aplicação deve-se
5116

52-
Você será avaliado pela usabilidade, por respeitar o design e pela arquitetura da API.
53-
É esperado que você consiga explicar as decisões que tomou durante o desenvolvimento através de commits.
17+
* [Iniciar o Eureka-server em um outro projeto do github]
18+
* [Iniciar este projeto como uma instancia do Eureka Server e acessá0lo via http:/localhos:8080]
19+
* [Criar as Categorias]
20+
* [Crias os gastos e testar as funcioanlidades]
5421

55-
* Springboot - Java - Maven (preferêncialmente) ([https://projects.spring.io/spring-boot/](https://projects.spring.io/spring-boot/))
56-
* RESTFul ([https://blog.mwaysolutions.com/2014/06/05/10-best-practices-for-better-restful-api/](https://blog.mwaysolutions.com/2014/06/05/10-best-practices-for-better-restful-api/))
57-
* DDD ([https://airbrake.io/blog/software-design/domain-driven-design](https://airbrake.io/blog/software-design/domain-driven-design))
58-
* Microservices ([https://martinfowler.com/microservices/](https://martinfowler.com/microservices/))
59-
* Testes unitários, teste o que achar importante (De preferência JUnit + Mockito). Mas pode usar o que você tem mais experiência, só nos explique o que ele tem de bom.
60-
* SOAPUI para testes de carga ([https://www.soapui.org/load-testing/concept.html](https://www.soapui.org/load-testing/concept.html))
61-
* Uso de diferentes formas de armazenamento de dados (REDIS, Cassandra, Solr/Lucene)
62-
* Uso do git
63-
* Diferencial: Criptografia de comunicação, com troca de chaves. ([http://noiseprotocol.org/](http://noiseprotocol.org/))
64-
* Diferencial: CQRS ([https://martinfowler.com/bliki/CQRS.html](https://martinfowler.com/bliki/CQRS.html))
65-
* Diferencial: Docker File + Docker Compose (com dbs) para rodar seus jars.
66-
67-
### # Observações gerais
68-
69-
Adicione um arquivo [README.md](http://README.md) com os procedimentos para executar o projeto.
70-
Pedimos que trabalhe sozinho e não divulgue o resultado na internet.
71-
72-
Faça um fork desse desse repositório em seu Github e nos envie um Pull Request com o resultado, por favor informe por qual empresa você esta se candidatando.
73-
74-
### # Importante: não há prazo de entrega, faça com qualidade!
75-
76-
# BOA SORTE!

build.gradle

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
buildscript {
2+
ext {
3+
springBootVersion = '2.0.2.RELEASE'
4+
}
5+
repositories {
6+
mavenCentral()
7+
}
8+
dependencies {
9+
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10+
}
11+
}
12+
13+
apply plugin: 'java'
14+
apply plugin: 'eclipse'
15+
apply plugin: 'org.springframework.boot'
16+
apply plugin: 'io.spring.dependency-management'
17+
18+
group = 'com.jps.example'
19+
version = '0.0.1-SNAPSHOT'
20+
sourceCompatibility = 1.8
21+
22+
repositories {
23+
mavenCentral()
24+
maven { url "https://repo.spring.io/milestone" }
25+
}
26+
27+
28+
ext {
29+
springCloudVersion = 'Finchley.RC2'
30+
}
31+
32+
dependencies {
33+
compile('org.springframework.boot:spring-boot-starter-web')
34+
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
35+
testCompile('org.springframework.boot:spring-boot-starter-test')
36+
}
37+
38+
dependencyManagement {
39+
imports {
40+
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
41+
}
42+
}

0 commit comments

Comments
 (0)