Browse Source

Implements test for search function over repository

feature-credentialneu
fdai5728 3 years ago
parent
commit
60626bc4f3
  1. 13
      src/main/java/CredentialRepository.java
  2. 3
      src/main/java/CredentialRepositoryInterface.java
  3. 11
      src/test/java/CredentialRepositoryTest.java

13
src/main/java/CredentialRepository.java

@ -33,8 +33,19 @@ public class CredentialRepository implements CredentialRepositoryInterface{
} }
public Credential getCredentialsViaName(String needle) {
for(int c = 0; c < this.getListSize(); c++)
{
}
return null;
}
@Override @Override
public void getCredentials() {
public void getCredentialsViaId() {
} }

3
src/main/java/CredentialRepositoryInterface.java

@ -3,7 +3,8 @@ public interface CredentialRepositoryInterface {
int createNewCredential(String name, String password); int createNewCredential(String name, String password);
void edit(); void edit();
void delete(); void delete();
void getCredentials();
void getCredentialsViaName();
void getCredentialsViaId();
void setCredentials(); void setCredentials();
void getAsJSON(); void getAsJSON();
void loadCredentialsFromJSON(); void loadCredentialsFromJSON();

11
src/test/java/CredentialRepositoryTest.java

@ -20,6 +20,17 @@ class CredentialRepositoryTest {
Assertions.assertEquals(2, this.credentialRepository.createNewCredential("kek", "mate")); Assertions.assertEquals(2, this.credentialRepository.createNewCredential("kek", "mate"));
} }
@Test
void searchForUserInRepository() {
this.credentialRepository.createNewCredential("mock", "mock");
this.credentialRepository.createNewCredential("kek", "mate");
Credential c = this.credentialRepository.getCredentialsViaName("kek");
Assertions.assertEquals("mate", c.getPassword());
}
} }

Loading…
Cancel
Save