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

Users Authentication Requests/Responses #53

Merged
merged 47 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4a10f5a
Created Users module, and added FreelancerRegister request and response
Akram-Fahim Mar 4, 2024
7c7b3b0
Updated added builder annotation to FreelancerRegisterResponse and re…
Akram-Fahim Mar 4, 2024
0ad77b0
Removed the NonNull annotation to make the class compatible with the …
Akram-Fahim Mar 4, 2024
8e40d00
Addressed @Ahmad45123's comments and created a test to verify the ser…
Akram-Fahim Mar 4, 2024
f9b11cf
Deleted commented file
Akram-Fahim Mar 8, 2024
9f2bf07
Revert "Deleted commented file"
Akram-Fahim Mar 8, 2024
8c87e35
Added all required Authentication (register/login) requests and respo…
Akram-Fahim Apr 28, 2024
dbdc281
Deleted useless file
Akram-Fahim Apr 28, 2024
1ab58d2
Created Users module, and added FreelancerRegister request and response
Akram-Fahim Mar 4, 2024
22abc27
Updated added builder annotation to FreelancerRegisterResponse and re…
Akram-Fahim Mar 4, 2024
fafeb94
Removed the NonNull annotation to make the class compatible with the …
Akram-Fahim Mar 4, 2024
a32128e
Addressed @Ahmad45123's comments and created a test to verify the ser…
Akram-Fahim Mar 4, 2024
0ce0bca
Deleted commented file
Akram-Fahim Mar 8, 2024
7621e89
Revert "Deleted commented file"
Akram-Fahim Mar 8, 2024
d14d33b
Added all required Authentication (register/login) requests and respo…
Akram-Fahim Apr 28, 2024
208bf61
Deleted useless file
Akram-Fahim Apr 28, 2024
1d7667e
Merge remote-tracking branch 'origin/users-auth' into users-auth
Akram-Fahim Apr 28, 2024
75bc0a7
Merge remote-tracking branch 'origin/main'
Akram-Fahim Apr 28, 2024
6438cd3
Created Users module, and added FreelancerRegister request and response
Akram-Fahim Mar 4, 2024
143521a
Updated added builder annotation to FreelancerRegisterResponse and re…
Akram-Fahim Mar 4, 2024
dfce4d7
Removed the NonNull annotation to make the class compatible with the …
Akram-Fahim Mar 4, 2024
d0b79d7
Addressed @Ahmad45123's comments and created a test to verify the ser…
Akram-Fahim Mar 4, 2024
1e8dd53
Deleted commented file
Akram-Fahim Mar 8, 2024
de0f05f
Revert "Deleted commented file"
Akram-Fahim Mar 8, 2024
7fbc77d
Added all required Authentication (register/login) requests and respo…
Akram-Fahim Apr 28, 2024
006288c
Deleted useless file
Akram-Fahim Apr 28, 2024
e498feb
Merge remote-tracking branch 'origin/users-auth' into users-auth
Akram-Fahim Apr 28, 2024
3d2ab3b
Updated the annotations to match the ones requested by @Ahmad45123
Akram-Fahim Apr 28, 2024
a5bbebc
Linting
Akram-Fahim Apr 28, 2024
8a8b9dc
Linting
Akram-Fahim Apr 28, 2024
28d15b0
Handled Inheritance bug
Akram-Fahim Apr 29, 2024
7128714
Removed the success boolean as suggested by @Ahmad45123
Akram-Fahim Apr 29, 2024
090ae5b
Addressed Noureldin's comments
Akram-Fahim May 1, 2024
0460a97
Created Users module, and added FreelancerRegister request and response
Akram-Fahim Mar 4, 2024
236c829
Addressed @Ahmad45123's comments and created a test to verify the ser…
Akram-Fahim Mar 4, 2024
10c08af
Created Users module, and added FreelancerRegister request and response
Akram-Fahim Mar 4, 2024
0839746
Addressed @Ahmad45123's comments and created a test to verify the ser…
Akram-Fahim Mar 4, 2024
e03e46b
Added all required Authentication (register/login) requests and respo…
Akram-Fahim Apr 28, 2024
2a604dd
Created Users module, and added FreelancerRegister request and response
Akram-Fahim Mar 4, 2024
d9cbbeb
Addressed @Ahmad45123's comments and created a test to verify the ser…
Akram-Fahim Mar 4, 2024
d767021
Added all required Authentication (register/login) requests and respo…
Akram-Fahim Apr 28, 2024
a2d9f3c
Updated the annotations to match the ones requested by @Ahmad45123
Akram-Fahim Apr 28, 2024
5570cd4
Linting
Akram-Fahim Apr 28, 2024
9297159
Handled Inheritance bug
Akram-Fahim Apr 29, 2024
2c23e55
Removed the success boolean as suggested by @Ahmad45123
Akram-Fahim Apr 29, 2024
07587e8
Addressed Noureldin's comments
Akram-Fahim May 1, 2024
7408d55
Merge branch 'users-auth' of https://github.com/Ahmad45123/workup int…
Akram-Fahim May 9, 2024
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
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
package com.workup.users;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.workup.shared.commands.users.requests.AuthenticationRequest;
import com.workup.shared.commands.users.requests.ClientRegisterRequest;
import com.workup.shared.commands.users.requests.FreelancerRegisterRequest;
import com.workup.shared.commands.users.responses.FreelancerRegisterResponse;
import com.workup.shared.commands.users.requests.LoginRequest;
import com.workup.shared.commands.users.responses.SignUpAndInResponse;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

public class RequestsAndResponsesTest {
private static Object[] testObjects = { // all requests/responses to be tested
FreelancerRegisterRequest.builder().build(), FreelancerRegisterResponse.builder().build(),
};
private static Object[] testObjects = { // all requests/responses to be tested
FreelancerRegisterRequest.builder().build(),
SignUpAndInResponse.builder().build(),
AuthenticationRequest.builder().build(),
ClientRegisterRequest.builder().build(),
LoginRequest.builder().build()
};

@Test
public void testSerializationNoExceptionsThrown() throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
for (Object testObject : testObjects) {
String className = testObject.getClass().getName();
assertDoesNotThrow(
() -> objectMapper.writeValueAsString(testObject),
String.format("Serialization of %s should not throw exceptions", className));
String json = objectMapper.writeValueAsString(testObject);
assertDoesNotThrow(
() -> objectMapper.readValue(json, testObject.getClass()),
String.format("Deserialization of %s should not throw exceptions", className));
@Test
public void testSerializationNoExceptionsThrown() throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
for (Object testObject : testObjects) {
String className = testObject.getClass().getName();
assertDoesNotThrow(
() -> objectMapper.writeValueAsString(testObject),
String.format("Serialization of %s should not throw exceptions", className)
);
String json = objectMapper.writeValueAsString(testObject);
assertDoesNotThrow(
() -> objectMapper.readValue(json, testObject.getClass()),
String.format("Deserialization of %s should not throw exceptions", className)
);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.workup.shared.commands.users.requests;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder(setterPrefix = "with")
@JsonDeserialize(builder = AuthenticationRequest.AuthenticationRequestBuilder.class)
Ahmad45123 marked this conversation as resolved.
Show resolved Hide resolved
public class AuthenticationRequest {
private String authToken;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.workup.shared.commands.users.requests;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder(setterPrefix = "with")
@JsonDeserialize(builder = ClientRegisterRequest.ClientRegisterRequestBuilder.class)
Ahmad45123 marked this conversation as resolved.
Show resolved Hide resolved
public class ClientRegisterRequest {
private String email;
private String passwordHash;
private String clientName;
private String industry;
private String city;
private String photoId;
private String description;
private Integer employeeCount;
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.workup.shared.commands.users.requests;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.workup.shared.commands.CommandRequest;
import java.util.Date;
import lombok.Builder;
import lombok.Getter;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;

import java.util.Date;

@Getter
@SuperBuilder(setterPrefix = "with")
@Jacksonized
Ahmad45123 marked this conversation as resolved.
Show resolved Hide resolved
@Builder(setterPrefix = "with")
@JsonDeserialize(builder = FreelancerRegisterRequest.FreelancerRegisterRequestBuilder.class)
public class FreelancerRegisterRequest extends CommandRequest {
Akram-Fahim marked this conversation as resolved.
Show resolved Hide resolved

String email;
String passwordHash;
String fullName;
String jobTitle;
String city;
Date birthDate;
private String email;
private String passwordHash;
private String fullName;
private String jobTitle;
private String city;
private Date birthDate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.workup.shared.commands.users.requests;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder(setterPrefix = "with")
@JsonDeserialize(builder = LoginRequest.LoginRequestBuilder.class)
Ahmad45123 marked this conversation as resolved.
Show resolved Hide resolved
public class LoginRequest {
Akram-Fahim marked this conversation as resolved.
Show resolved Hide resolved
private String email;
private String passwordHash;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.workup.shared.commands.users.responses;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder(setterPrefix = "with")
@JsonDeserialize(builder = AuthenticationResponse.AuthenticationResponseBuilder.class)
Ahmad45123 marked this conversation as resolved.
Show resolved Hide resolved
public class AuthenticationResponse {
private String email;
private UserType userType;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.workup.shared.commands.users.responses;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.workup.shared.commands.CommandResponse;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder(setterPrefix = "with")
@JsonDeserialize(builder = SignUpAndInResponse.SignUpAndInResponseBuilder.class)
Ahmad45123 marked this conversation as resolved.
Show resolved Hide resolved
public class SignUpAndInResponse extends CommandResponse {
boolean success;
String authToken;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.workup.shared.commands.users.responses;

public enum UserType {
FREELANCER,
CLIENT
}
Loading