From 57ae190c6358f71bc8a511719aab448d0b272d84 Mon Sep 17 00:00:00 2001 From: fdai5728 Date: Wed, 16 Feb 2022 18:02:06 +0100 Subject: [PATCH] Implements Unittest and function to delete credential from arraylist --- src/main/java/CredentialRepository.java | 2 ++ src/test/java/CredentialRepositoryTest.java | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/CredentialRepository.java b/src/main/java/CredentialRepository.java index c47d507..8e1adc9 100644 --- a/src/main/java/CredentialRepository.java +++ b/src/main/java/CredentialRepository.java @@ -86,6 +86,8 @@ public class CredentialRepository implements CredentialRepositoryInterface{ @Override public void delete(int index) { + this.credentials.remove(index); + } diff --git a/src/test/java/CredentialRepositoryTest.java b/src/test/java/CredentialRepositoryTest.java index b7b0674..3806d09 100644 --- a/src/test/java/CredentialRepositoryTest.java +++ b/src/test/java/CredentialRepositoryTest.java @@ -70,6 +70,19 @@ class CredentialRepositoryTest { Credential c = this.credentialRepository.getCredentialsViaId(0); Assertions.assertEquals("newUsername", c.getName()); + } + + @Test + void testDeleteEntry(){ + + this.credentialRepository.createNewCredential("mock", "mock"); + this.credentialRepository.delete(0); + + Assertions.assertEquals(null, this.credentialRepository.getCredentialsViaId(0)); + } + + @Test + void testIndexShiftAfterDeletion(){ }