├── meetupmanager
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── demo
│ │ │ └── meetupmanager
│ │ │ ├── exception
│ │ │ └── BusinessException.java
│ │ │ ├── service
│ │ │ ├── RegistrationService.java
│ │ │ └── impl
│ │ │ │ └── RegistrationServiceImpl.java
│ │ │ ├── controller
│ │ │ ├── dto
│ │ │ │ ├── RegisteredMeetupDTO.java
│ │ │ │ ├── MeetupFilterDTO.java
│ │ │ │ ├── MeetupDTO.java
│ │ │ │ └── RegistrationDTO.java
│ │ │ ├── exceptions
│ │ │ │ └── ApiErrors.java
│ │ │ ├── web
│ │ │ │ └── RegistrationController.java
│ │ │ └── ApplicationControllerAdvice.java
│ │ │ ├── MeetupmanagerApplication.java
│ │ │ ├── repository
│ │ │ └── RegistrationRepository.java
│ │ │ └── model
│ │ │ ├── Meetup.java
│ │ │ └── Registration.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── demo
│ │ └── meetupmanager
│ │ ├── MeetupmanagerApplicationTests.java
│ │ ├── repository
│ │ └── RegistrationRepositoryTest.java
│ │ ├── service
│ │ └── RegistrationServiceTest.java
│ │ └── controller
│ │ └── RegistrationControllerTest.java
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── .gitignore
├── build.gradle
├── gradlew.bat
└── gradlew
├── README.md
└── .idea
├── .gitignore
├── codeStyles
└── codeStyleConfig.xml
├── misc.xml
├── gradle.xml
└── dbnavigator.xml
/meetupmanager/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/meetupmanager/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'meetupmanager'
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # live-meetup-manager
2 |
3 | Projeto ministrado em live!
4 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/meetupmanager/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ananeridev/meetup-manager/HEAD/meetupmanager/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/meetupmanager/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/exception/BusinessException.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.exception;
2 |
3 | public class BusinessException extends RuntimeException {
4 | public BusinessException(String s) {
5 | super(s);
6 | }
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/service/RegistrationService.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.service;
2 |
3 | import com.demo.meetupmanager.model.Registration;
4 |
5 | public interface RegistrationService {
6 |
7 | Registration save(Registration any);
8 | }
9 |
--------------------------------------------------------------------------------
/meetupmanager/src/test/java/com/demo/meetupmanager/MeetupmanagerApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class MeetupmanagerApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/controller/dto/RegisteredMeetupDTO.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.controller.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | @Builder
9 | @AllArgsConstructor
10 | @NoArgsConstructor
11 | @Data
12 | public class RegisteredMeetupDTO {
13 |
14 | private Boolean registered;
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/MeetupmanagerApplication.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class MeetupmanagerApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(MeetupmanagerApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/controller/dto/MeetupFilterDTO.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.controller.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | @Data
9 | @AllArgsConstructor
10 | @NoArgsConstructor
11 | @Builder
12 | public class MeetupFilterDTO {
13 |
14 | private String registration;
15 |
16 | private String event;
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/repository/RegistrationRepository.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.repository;
2 |
3 | import com.demo.meetupmanager.model.Registration;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | import java.util.Optional;
7 |
8 | public interface RegistrationRepository extends JpaRepository {
9 |
10 | boolean existsByRegistration(String registration);
11 |
12 | Optional findByRegistration(String registrationAtrb);
13 | }
14 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/controller/dto/MeetupDTO.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.controller.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | @Data
9 | @Builder
10 | @NoArgsConstructor
11 | @AllArgsConstructor
12 | public class MeetupDTO {
13 |
14 |
15 | private Integer id;
16 |
17 | private String registrationAttribute;
18 |
19 | private String event;
20 |
21 | private RegistrationDTO registration;
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/meetupmanager/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | .gradle
3 | build/
4 | !gradle/wrapper/gradle-wrapper.jar
5 | !**/src/main/**/build/
6 | !**/src/test/**/build/
7 |
8 | ### STS ###
9 | .apt_generated
10 | .classpath
11 | .factorypath
12 | .project
13 | .settings
14 | .springBeans
15 | .sts4-cache
16 | bin/
17 | !**/src/main/**/bin/
18 | !**/src/test/**/bin/
19 |
20 | ### IntelliJ IDEA ###
21 | .idea
22 | *.iws
23 | *.iml
24 | *.ipr
25 | out/
26 | !**/src/main/**/out/
27 | !**/src/test/**/out/
28 |
29 | ### NetBeans ###
30 | /nbproject/private/
31 | /nbbuild/
32 | /dist/
33 | /nbdist/
34 | /.nb-gradle/
35 |
36 | ### VS Code ###
37 | .vscode/
38 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
16 |
17 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/controller/dto/RegistrationDTO.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.controller.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import javax.validation.constraints.NotEmpty;
9 |
10 | @Data
11 | @AllArgsConstructor
12 | @NoArgsConstructor
13 | @Builder
14 | public class RegistrationDTO {
15 |
16 | private Integer id;
17 |
18 | @NotEmpty
19 | private String name;
20 |
21 | @NotEmpty
22 | private String dateOfRegistration;
23 |
24 | @NotEmpty
25 | private String registration;
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/model/Meetup.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.model;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import javax.persistence.*;
9 |
10 | @Data
11 | @NoArgsConstructor
12 | @AllArgsConstructor
13 | @Builder
14 | @Entity
15 | public class Meetup {
16 |
17 | @Id
18 | @GeneratedValue(strategy = GenerationType.IDENTITY)
19 | private Integer id;
20 |
21 | @Column
22 | private String event;
23 |
24 | @JoinColumn(name = "id_registration")
25 | @ManyToOne
26 | private Registration registration;
27 |
28 | @Column
29 | private String meetupDate;
30 |
31 | @Column
32 | private Boolean registered;
33 | }
34 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/model/Registration.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.model;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Builder;
5 | import lombok.Data;
6 | import lombok.NoArgsConstructor;
7 |
8 | import javax.persistence.*;
9 | import java.util.List;
10 |
11 | @Data
12 | @AllArgsConstructor
13 | @NoArgsConstructor
14 | @Builder
15 | @Entity
16 | @Table
17 | public class Registration {
18 |
19 | @Id
20 | @Column(name = "registration_id")
21 | @GeneratedValue(strategy = GenerationType.IDENTITY)
22 | private Integer id;
23 |
24 | @Column(name = "person_name")
25 | private String name;
26 |
27 | @Column(name = "date_of_registration")
28 | private String dateOfRegistration;
29 |
30 | @Column
31 | private String registration;
32 |
33 | @OneToMany(mappedBy = "registration")
34 | private List meetups;
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/service/impl/RegistrationServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.service.impl;
2 |
3 | import com.demo.meetupmanager.exception.BusinessException;
4 | import com.demo.meetupmanager.model.Registration;
5 | import com.demo.meetupmanager.repository.RegistrationRepository;
6 | import com.demo.meetupmanager.service.RegistrationService;
7 | import org.springframework.stereotype.Service;
8 |
9 | @Service
10 | public class RegistrationServiceImpl implements RegistrationService {
11 |
12 |
13 | RegistrationRepository repository;
14 |
15 | public RegistrationServiceImpl(RegistrationRepository repository) {
16 | this.repository = repository;
17 | }
18 |
19 | public Registration save(Registration registration) {
20 | if (repository.existsByRegistration(registration.getRegistration())) {
21 | throw new BusinessException("Registration Already created");
22 | }
23 | return repository.save(registration);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/controller/exceptions/ApiErrors.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.controller.exceptions;
2 |
3 | import com.demo.meetupmanager.exception.BusinessException;
4 | import org.springframework.validation.BindingResult;
5 | import org.springframework.web.server.ResponseStatusException;
6 |
7 | import java.util.ArrayList;
8 | import java.util.Arrays;
9 | import java.util.List;
10 |
11 | public class ApiErrors {
12 | private final List errors;
13 |
14 | public ApiErrors(BindingResult bindingResult) {
15 | this.errors = new ArrayList<>();
16 | bindingResult.getAllErrors()
17 | .forEach(error -> this.errors.add(error.getDefaultMessage()));
18 | }
19 |
20 | public ApiErrors(BusinessException e) {
21 | this.errors = Arrays.asList(e.getMessage());
22 | }
23 |
24 | public ApiErrors(ResponseStatusException e) {
25 | this.errors = Arrays.asList(e.getReason());
26 | }
27 |
28 | public List getErrors() {
29 | return errors;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/meetupmanager/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'org.springframework.boot' version '2.7.1'
3 | id 'io.spring.dependency-management' version '1.0.11.RELEASE'
4 | id 'java'
5 | }
6 |
7 | group = 'com.demo'
8 | version = '0.0.1-SNAPSHOT'
9 | sourceCompatibility = '11'
10 |
11 | configurations {
12 | compileOnly {
13 | extendsFrom annotationProcessor
14 | }
15 | }
16 |
17 | repositories {
18 | mavenCentral()
19 | }
20 |
21 | ext {
22 | set('testcontainersVersion', "1.16.2")
23 | }
24 |
25 | dependencies {
26 | implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
27 | implementation 'org.springframework.boot:spring-boot-starter-validation'
28 | implementation 'org.springframework.boot:spring-boot-starter-web'
29 | implementation 'org.modelmapper:modelmapper:3.0.0'
30 | implementation 'io.springfox:springfox-boot-starter:3.0.0'
31 | compileOnly 'org.projectlombok:lombok'
32 | runtimeOnly 'com.h2database:h2'
33 | annotationProcessor 'org.projectlombok:lombok'
34 | testImplementation 'org.springframework.boot:spring-boot-starter-test'
35 | testImplementation 'org.testcontainers:junit-jupiter'
36 |
37 | }
38 |
39 | dependencyManagement {
40 | imports {
41 | mavenBom "org.testcontainers:testcontainers-bom:${testcontainersVersion}"
42 | }
43 | }
44 |
45 |
46 | tasks.named('test') {
47 | useJUnitPlatform()
48 | }
49 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/controller/web/RegistrationController.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.controller.web;
2 |
3 | import com.demo.meetupmanager.controller.dto.RegistrationDTO;
4 | import com.demo.meetupmanager.model.Registration;
5 | import com.demo.meetupmanager.service.RegistrationService;
6 | import org.modelmapper.ModelMapper;
7 | import org.springframework.http.HttpStatus;
8 | import org.springframework.web.bind.annotation.*;
9 |
10 | import javax.validation.Valid;
11 |
12 | @RestController
13 | @RequestMapping("/api/registration")
14 | public class RegistrationController {
15 |
16 | private RegistrationService registrationService;
17 |
18 | private ModelMapper modelMapper;
19 |
20 |
21 | public RegistrationController(RegistrationService registrationService, ModelMapper modelMapper) {
22 | this.registrationService = registrationService;
23 | this.modelMapper = modelMapper;
24 | }
25 |
26 | @PostMapping
27 | @ResponseStatus(HttpStatus.CREATED)
28 | public RegistrationDTO create(@RequestBody @Valid RegistrationDTO dto) {
29 |
30 | Registration entity = modelMapper.map(dto, Registration.class);
31 | entity = registrationService.save(entity);
32 |
33 | return modelMapper.map(entity, RegistrationDTO.class);
34 | }
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/meetupmanager/src/main/java/com/demo/meetupmanager/controller/ApplicationControllerAdvice.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.controller;
2 |
3 | import com.demo.meetupmanager.controller.exceptions.ApiErrors;
4 | import com.demo.meetupmanager.exception.BusinessException;
5 | import org.springframework.http.HttpStatus;
6 | import org.springframework.http.ResponseEntity;
7 | import org.springframework.validation.BindingResult;
8 | import org.springframework.web.bind.MethodArgumentNotValidException;
9 | import org.springframework.web.bind.annotation.ExceptionHandler;
10 | import org.springframework.web.bind.annotation.ResponseStatus;
11 | import org.springframework.web.bind.annotation.RestControllerAdvice;
12 | import org.springframework.web.server.ResponseStatusException;
13 |
14 | @RestControllerAdvice
15 | public class ApplicationControllerAdvice {
16 |
17 | @ExceptionHandler(MethodArgumentNotValidException.class)
18 | @ResponseStatus(HttpStatus.BAD_REQUEST)
19 | public ApiErrors handleValidateException(MethodArgumentNotValidException e) {
20 | BindingResult bindingResult = e.getBindingResult();
21 | return new ApiErrors(bindingResult);
22 | }
23 |
24 |
25 | @ExceptionHandler(BusinessException.class)
26 | @ResponseStatus(HttpStatus.BAD_REQUEST)
27 | public ApiErrors handleBusinessException(BusinessException e) {
28 | return new ApiErrors(e);
29 | }
30 |
31 |
32 | @ExceptionHandler(ResponseStatusException.class)
33 | @ResponseStatus
34 | public ResponseEntity handleResponseStatusException(ResponseStatusException ex) {
35 | return new ResponseEntity(new ApiErrors(ex), ex.getStatus());
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/meetupmanager/src/test/java/com/demo/meetupmanager/repository/RegistrationRepositoryTest.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.repository;
2 |
3 | import com.demo.meetupmanager.model.Registration;
4 | import org.junit.jupiter.api.DisplayName;
5 | import org.junit.jupiter.api.Test;
6 | import org.junit.jupiter.api.extension.ExtendWith;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
9 | import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
10 | import org.springframework.test.context.ActiveProfiles;
11 | import org.springframework.test.context.junit.jupiter.SpringExtension;
12 |
13 | import java.util.Optional;
14 |
15 | import static org.assertj.core.api.Assertions.assertThat;
16 |
17 |
18 | @ExtendWith(SpringExtension.class)
19 | @ActiveProfiles("test")
20 | @DataJpaTest
21 | public class RegistrationRepositoryTest {
22 |
23 | @Autowired
24 | TestEntityManager testEntityManager;
25 |
26 | @Autowired
27 | RegistrationRepository repository;
28 |
29 |
30 | @Test
31 | @DisplayName("Should return true when exists an registration already created.")
32 | public void returnTrueWhenRegistrationExists() {
33 |
34 | String registration = "123";
35 |
36 | Registration registration_class_attribute = createNewRegistration(registration);
37 | testEntityManager.persist(registration_class_attribute);
38 |
39 | boolean exists = repository.existsByRegistration(registration);
40 |
41 | assertThat(exists).isTrue();
42 |
43 | }
44 |
45 | @Test
46 | @DisplayName("Should return false when doesn't exists an registration_attribute with a registration already created.")
47 | public void returnFalseWhenRegistrationAttributeDoesntExists() {
48 |
49 | String registration = "123";
50 |
51 | boolean exists = repository.existsByRegistration(registration);
52 |
53 | assertThat(exists).isFalse();
54 |
55 | }
56 |
57 |
58 |
59 | public static Registration createNewRegistration(String registration) {
60 | return Registration.builder()
61 | .name("ana")
62 | .dateOfRegistration("13/07/2022")
63 | .registration(registration).build();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/meetupmanager/src/test/java/com/demo/meetupmanager/service/RegistrationServiceTest.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.service;
2 |
3 | import com.demo.meetupmanager.model.Registration;
4 | import com.demo.meetupmanager.repository.RegistrationRepository;
5 | import com.demo.meetupmanager.service.impl.RegistrationServiceImpl;
6 | import org.junit.jupiter.api.BeforeEach;
7 | import org.junit.jupiter.api.DisplayName;
8 | import org.junit.jupiter.api.Test;
9 | import org.junit.jupiter.api.extension.ExtendWith;
10 | import org.mockito.Mockito;
11 | import org.springframework.boot.test.mock.mockito.MockBean;
12 | import org.springframework.test.context.ActiveProfiles;
13 | import org.springframework.test.context.junit.jupiter.SpringExtension;
14 |
15 | import static org.assertj.core.api.Assertions.assertThat;
16 |
17 | @ExtendWith(SpringExtension.class)
18 | @ActiveProfiles("test")
19 | public class RegistrationServiceTest {
20 |
21 | RegistrationService registrationService;
22 |
23 | @MockBean
24 | RegistrationRepository repository;
25 |
26 |
27 | @BeforeEach
28 | public void setUp() {
29 | this.registrationService = new RegistrationServiceImpl(repository);
30 | }
31 |
32 | @Test
33 | @DisplayName("Should save an registration")
34 | public void saveRegistration() {
35 |
36 | Registration registration = createValidRegistration();
37 |
38 | Mockito.when(repository.existsByRegistration(Mockito.anyString())).thenReturn(false);
39 | Mockito.when(repository.save(registration)).thenReturn(createValidRegistration());
40 |
41 | Registration savedRegistration = registrationService.save(registration);
42 |
43 | assertThat(savedRegistration.getId()).isEqualTo(101);
44 | assertThat(savedRegistration.getName()).isEqualTo("Ana Neri");
45 | assertThat(savedRegistration.getDateOfRegistration()).isEqualTo("01/04/2022");
46 | assertThat(savedRegistration.getRegistration()).isEqualTo("001");
47 | }
48 |
49 |
50 |
51 |
52 |
53 |
54 | private Registration createValidRegistration() {
55 | return Registration.builder()
56 | .id(101)
57 | .name("Ana Neri")
58 | .dateOfRegistration("01/04/2022")
59 | .registration("001")
60 | .build();
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/meetupmanager/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/meetupmanager/src/test/java/com/demo/meetupmanager/controller/RegistrationControllerTest.java:
--------------------------------------------------------------------------------
1 | package com.demo.meetupmanager.controller;
2 |
3 | import com.demo.meetupmanager.controller.dto.RegistrationDTO;
4 | import com.demo.meetupmanager.controller.web.RegistrationController;
5 | import com.demo.meetupmanager.model.Registration;
6 | import com.demo.meetupmanager.service.RegistrationService;
7 | import org.junit.jupiter.api.DisplayName;
8 | import org.junit.jupiter.api.Test;
9 | import org.junit.jupiter.api.extension.ExtendWith;
10 | import org.mockito.BDDMockito;
11 | import org.springframework.beans.factory.annotation.Autowired;
12 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
13 | import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
14 | import org.springframework.boot.test.mock.mockito.MockBean;
15 | import org.springframework.http.MediaType;
16 | import org.springframework.test.context.ActiveProfiles;
17 | import org.springframework.test.context.junit.jupiter.SpringExtension;
18 | import org.springframework.test.web.servlet.MockMvc;
19 | import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
20 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
21 |
22 | import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;
23 |
24 |
25 | import static org.hamcrest.Matchers.hasSize;
26 | import static org.mockito.Mockito.*;
27 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
28 |
29 | @ExtendWith(SpringExtension.class)
30 | @ActiveProfiles("test")
31 | @WebMvcTest(controllers = {RegistrationController.class})
32 | @AutoConfigureMockMvc
33 | public class RegistrationControllerTest {
34 |
35 |
36 | static String REGISTRATION_API = "/api/registration";
37 |
38 | @Autowired
39 | MockMvc mockMvc;
40 |
41 | @MockBean
42 | RegistrationService registrationService;
43 |
44 | @Test
45 | @DisplayName("Should create a registration with success")
46 | public void createRegistrationTest() throws Exception {
47 |
48 | // cenario
49 | RegistrationDTO registrationDTOBuilder = createNewRegistration();
50 | Registration savedRegistration = Registration.builder().id(101)
51 | .name("Ana Neri").dateOfRegistration("10/10/2021").registration("001").build();
52 |
53 |
54 | // execucao
55 | BDDMockito.given(registrationService.save(any(Registration.class))).willReturn(savedRegistration);
56 |
57 |
58 | String json = new ObjectMapper().writeValueAsString(registrationDTOBuilder);
59 |
60 |
61 | MockHttpServletRequestBuilder request = MockMvcRequestBuilders
62 | .post(REGISTRATION_API)
63 | .contentType(MediaType.APPLICATION_JSON)
64 | .accept(MediaType.APPLICATION_JSON)
65 | .content(json);
66 |
67 | // verificacao, assert....
68 | mockMvc
69 | .perform(request)
70 | .andExpect(status().isCreated())
71 | .andExpect(jsonPath("id").value(101))
72 | .andExpect(jsonPath("name").value(registrationDTOBuilder.getName()))
73 | .andExpect(jsonPath("dateOfRegistration").value(registrationDTOBuilder.getDateOfRegistration()))
74 | .andExpect(jsonPath("registration").value(registrationDTOBuilder.getRegistration()));
75 | }
76 |
77 |
78 | private RegistrationDTO createNewRegistration() {
79 | return RegistrationDTO.builder().id(101).name("Ana Neri").dateOfRegistration("10/10/2021").registration("001").build();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/meetupmanager/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # 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, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Use "xargs" to parse quoted args.
209 | #
210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211 | #
212 | # In Bash we could simply go:
213 | #
214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215 | # set -- "${ARGS[@]}" "$@"
216 | #
217 | # but POSIX shell has neither arrays nor command substitution, so instead we
218 | # post-process each arg (as a line of input to sed) to backslash-escape any
219 | # character that might be a shell metacharacter, then use eval to reverse
220 | # that process (while maintaining the separation between arguments), and wrap
221 | # the whole thing up as a single "set" statement.
222 | #
223 | # This will of course break if any of these variables contains a newline or
224 | # an unmatched quote.
225 | #
226 |
227 | eval "set -- $(
228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229 | xargs -n1 |
230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231 | tr '\n' ' '
232 | )" '"$@"'
233 |
234 | exec "$JAVACMD" "$@"
235 |
--------------------------------------------------------------------------------
/.idea/dbnavigator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
--------------------------------------------------------------------------------