Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests #23

Merged
merged 17 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@
</execution>
<execution>
<configuration>

<haltOnFailure>true</haltOnFailure>
<includes>
<include>**/controller/*</include>
</includes>
<rules>
<rule>
<element>PACKAGE</element>
<limits>
<limit>
<counter>LINE</counter>
<minimum>0.0</minimum>
<minimum>0.80</minimum>
<value>COVEREDRATIO</value>
</limit>
</limits>
Expand Down Expand Up @@ -168,6 +172,29 @@
<groupId>org.junit.jupiter</groupId>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>junit-jupiter</artifactId>
<groupId>org.testcontainers</groupId>
<scope>test</scope>
<version>1.19.8</version>
</dependency>
<dependency>
<artifactId>postgresql</artifactId>
<groupId>org.testcontainers</groupId>
<scope>test</scope>
<version>1.19.8</version>
</dependency>
<dependency>
<artifactId>kafka</artifactId>
<groupId>org.testcontainers</groupId>
<scope>test</scope>
<version>1.19.8</version>
</dependency>
<dependency>
<artifactId>jjwt</artifactId>
<groupId>io.jsonwebtoken</groupId>
<version>0.9.1</version>
</dependency>
</dependencies>
<description>A simple API for internet provider</description>
<developers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public List<PlanDto> findAllPlans() {
* @throws PlanNotFoundException the plan not found exception
*/
@GetMapping("/{planId}")
@PreAuthorize("hasAnyAuthority('ADMIN', 'TECHNICIAN')")
public PlanDto findPlanById(@PathVariable Long planId)
throws PlanNotFoundException {
return PlanDto.fromEntity(planService.findPlanById(planId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* The type Technician dto.
*/
public record TechnicianDto(Long id, String name, String phone, String email) {
public record TechnicianDto(Long id, String fullName, String phone, String email) {

/**
* From entity technician dto.
Expand Down
26 changes: 23 additions & 3 deletions src/main/java/com/maires/wnet/entity/Installation.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public Installation() {
/**
* Instantiates a new Installation.
*
* @param address the address id
* @param plan the plan id
* @param technician the technician id
* @param address the address
* @param plan the plan
* @param technician the technician
* @param equipments the equipments
*/
public Installation(Address address, Plan plan, Technician technician,
Expand All @@ -68,6 +68,26 @@ public Installation(Address address, Plan plan, Technician technician,
this.installationDate = DateUtil.formatCurrentDate();
}


/**
* Instantiates a new Installation.
*
* @param isActive the is active
* @param address the address
* @param plan the plan
* @param technician the technician
* @param equipments the equipments
*/
public Installation(boolean isActive, Address address, Plan plan, Technician technician,
List<Equipment> equipments) {
this.isActive = isActive;
this.address = address;
this.plan = plan;
this.technician = technician;
this.equipments = equipments;
this.installationDate = DateUtil.formatCurrentDate();
}

/**
* Gets id.
*
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/maires/wnet/entity/Plan.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public Plan() {
/**
* Instantiates a new Plan.
*
* @param fullName the full name
* @param speed the speed
* @param price the price
* @param name the name
* @param speed the speed
* @param price the price
*/
public Plan(String fullName, Integer speed, Double price) {
this.name = fullName;
public Plan(String name, Integer speed, Double price) {
this.name = name;
this.speed = speed;
this.price = price;
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/maires/wnet/entity/Technician.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public Technician() {
/**
* Instantiates a new Technician.
*
* @param name the fullName
* @param phone the phone
* @param email the email
* @param fullName the fullName
* @param phone the phone
* @param email the email
*/
public Technician(String name, String phone, String email) {
this.fullName = name;
public Technician(String fullName, String phone, String email) {
this.fullName = fullName;
this.phone = phone;
this.email = email;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/maires/wnet/security/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws
).authorizeHttpRequests(authorize -> authorize
.requestMatchers(HttpMethod.GET, "/swagger-ui/**").permitAll()
.requestMatchers(HttpMethod.GET, "/v3/**").permitAll()
.requestMatchers(HttpMethod.GET, "/plans", "/plans/{planId}").permitAll()
.requestMatchers(HttpMethod.POST, "/users").permitAll()
.requestMatchers(HttpMethod.POST, "/auth/login").permitAll()
.anyRequest().authenticated()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/maires/wnet/service/AddressService.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public Address updateAddress(Long addressId, Address address) throws AddressNotF
addressToUpdate.setCity(address.getCity());
addressToUpdate.setState(address.getState());
addressToUpdate.setZipCode(address.getZipCode());
addressToUpdate.setStreet(addressToUpdate.getStreet());
addressToUpdate.setStreet(address.getStreet());
addressToUpdate.setStreetNumber(address.getStreetNumber());
addressToUpdate.setNeighborhood(address.getNeighborhood());
addressToUpdate.setComplement(address.getComplement());
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:postgres}
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
# Hibernate configuration
spring.jpa.hibernate.ddl-auto=create-drop
#spring.jpa.hibernate.ddl-auto=updateUser
spring.jpa.show-sql=true
spring.application.name=w-net-internet
# JWT configuration
api.security.token.secret=${JWT_SECRET:mySuperSuperSecret}
# Kafka configuration
kafka.topic=installation-completed
spring.kafka.bootstrap-servers=${KAFKA_HOST:localhost}:9092
Expand Down
21 changes: 0 additions & 21 deletions src/main/resources/application-test.properties

This file was deleted.

4 changes: 1 addition & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
spring.profiles.active=dev
api.security.token.secret=${JWT_SECRET:mySuperSuperSecret}
spring.jpa.hibernate.ddl-auto=create-drop
spring.profiles.active=dev
27 changes: 0 additions & 27 deletions src/test/java/com/maires/wnet/WnetInternetApplicationTests.java

This file was deleted.

Loading
Loading