Skip to content

Commit d656f20

Browse files
committed
fix: resolve test compilation errors and update tests for PDF support
- Add missing downloadFileBytes() override to FakeGoogleDriveApiClient - Fix BaseResumeContentResponse constructor call missing readOnly argument - Update PDF rejection tests to use unsupported MIME type (docx) since PDFs are now accepted as read-only resumes - Fix McpAuthIT setUp by deleting google_drive_connections before users to avoid FK constraint violation https://claude.ai/code/session_01WsXBePpMyKd57McmFAyyTQ
1 parent 689c3f8 commit d656f20

4 files changed

Lines changed: 19 additions & 11 deletions

File tree

src/test/java/com/jobtracker/integration/GoogleDriveControllerIT.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,20 +236,20 @@ void addBaseResume_shouldPersistResumeAndReturn201() throws Exception {
236236
}
237237

238238
@Test
239-
void addBaseResume_shouldRejectNonGoogleDocsFile() throws Exception {
239+
void addBaseResume_shouldRejectUnsupportedFileType() throws Exception {
240240
googleDriveConnectionRepository.save(buildConnection());
241-
googleDriveApiClient.fileMetadataById.put("pdf-file",
241+
googleDriveApiClient.fileMetadataById.put("docx-file",
242242
new GoogleDriveApiClient.DriveFileMetadata(
243-
"pdf-file",
244-
"Resume.pdf",
245-
"application/pdf",
243+
"docx-file",
244+
"Resume.docx",
245+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
246246
null
247247
));
248248

249249
mockMvc.perform(post("/api/v1/google-drive/base-resumes")
250250
.header("Authorization", "Bearer " + betaAccessToken)
251251
.contentType(MediaType.APPLICATION_JSON)
252-
.content("{\"documentIdOrUrl\":\"pdf-file\"}"))
252+
.content("{\"documentIdOrUrl\":\"docx-file\"}"))
253253
.andExpect(status().isBadRequest());
254254
}
255255

@@ -671,5 +671,10 @@ public void replaceGoogleDocPlaceholders(String accessToken, String documentId,
671671
public DriveFileMetadata exportGoogleDocAsPdf(String accessToken, String documentId, String targetFolderId, String pdfName) {
672672
return new DriveFileMetadata("pdf-file", pdfName, "application/pdf", null);
673673
}
674+
675+
@Override
676+
public byte[] downloadFileBytes(String accessToken, String fileId) {
677+
return new byte[0];
678+
}
674679
}
675680
}

src/test/java/com/jobtracker/integration/mcp/McpAuthIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.jobtracker.dto.auth.AuthResponse;
55
import com.jobtracker.dto.auth.RegisterRequest;
66
import com.jobtracker.integration.AbstractIntegrationTest;
7+
import com.jobtracker.repository.GoogleDriveConnectionRepository;
78
import com.jobtracker.repository.RefreshTokenRepository;
89
import com.jobtracker.repository.UserRepository;
910
import org.junit.jupiter.api.BeforeEach;
@@ -48,11 +49,13 @@ class McpAuthIT extends AbstractIntegrationTest {
4849
@Autowired private ObjectMapper objectMapper;
4950
@Autowired private UserRepository userRepository;
5051
@Autowired private RefreshTokenRepository refreshTokenRepository;
52+
@Autowired private GoogleDriveConnectionRepository googleDriveConnectionRepository;
5153

5254
private String accessToken;
5355

5456
@BeforeEach
5557
void setUp() throws Exception {
58+
googleDriveConnectionRepository.deleteAll();
5659
refreshTokenRepository.deleteAll();
5760
userRepository.deleteAll();
5861

src/test/java/com/jobtracker/unit/GoogleDriveServiceTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,20 @@ void updateRootFolder_shouldPersistFolderMetadata() {
143143
}
144144

145145
@Test
146-
void addBaseResume_shouldRejectNonGoogleDocsFiles() {
146+
void addBaseResume_shouldRejectUnsupportedFileTypes() {
147147
when(securityUtils.getCurrentUserId()).thenReturn(USER_ID);
148148
when(connectionRepository.findByUserId(USER_ID)).thenReturn(Optional.of(connection));
149149
when(googleDriveApiClient.getFileMetadata("access-token", "not-a-doc"))
150150
.thenReturn(new GoogleDriveApiClient.DriveFileMetadata(
151151
"not-a-doc",
152-
"Resume.pdf",
153-
"application/pdf",
152+
"Resume.docx",
153+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
154154
null
155155
));
156156

157157
assertThatThrownBy(() -> googleDriveService.addBaseResume(new GoogleDriveBaseResumeRequest("not-a-doc", null, false)))
158158
.isInstanceOf(BadRequestException.class)
159-
.hasMessageContaining("Only Google Docs base resumes are supported");
159+
.hasMessageContaining("Only Google Docs documents and PDF files are supported");
160160
}
161161

162162
@Test

src/test/java/com/jobtracker/unit/mcp/McpResumeContentResourcesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class McpResumeContentResourcesTest {
3131
@Test
3232
void baseResumeContent_readsRequestedResourceAndReturnsText() {
3333
UUID resumeId = UUID.randomUUID();
34-
BaseResumeContentResponse response = new BaseResumeContentResponse(resumeId, "Base CV", "EN", true, "base-text");
34+
BaseResumeContentResponse response = new BaseResumeContentResponse(resumeId, "Base CV", "EN", true, false, "base-text");
3535
when(resumeGenerationService.getBaseResumeContent(resumeId)).thenReturn(response);
3636

3737
String result = baseResumeContentResource.baseResumeContent(resumeId.toString());

0 commit comments

Comments
 (0)