Browse Source

add rename method plus test

chore-betterServerTestCoverage
Steffen Nitschke 4 years ago
parent
commit
807f47c516
  1. 14
      Jenkinsfile
  2. 5
      fh.fd.ci.server/src/main/java/de/fd/fh/server/access/Access.java
  3. 7
      fh.fd.ci.server/src/main/java/de/fd/fh/server/access/AccessService.java
  4. 48
      fh.fd.ci.server/src/test/java/de/fd/fh/server/access/AccessTest.java

14
Jenkinsfile

@ -60,20 +60,6 @@ pipeline {
success { success {
// script {
//
// sh "'${env.BRANCH_NAME}'"
// if (${env.BRANCH_NAME}.startsWith('pr-')) {
//
//// git url: "git@gogs.informatik.hs-fulda.de:SteffenN/Multi-Chess.git",
//// credentialsId: 'jenkins_ssh_key',
//// branch: (env.BRANCH_NAME)
//
// sh "git merge '${env.BRANCH_NAME}'"
// sh "git commit -am 'Merged ${env.BRANCH_NAME} branch to master'"
// sh "git push origin master"
// }
// }
office365ConnectorSend color: 'good', office365ConnectorSend color: 'good',
message: "Build ${currentBuild.fullDisplayName} completed *successfully* (<${BUILD_URL}>).\n\n\n${CUSTOM_SCM_INFO}", message: "Build ${currentBuild.fullDisplayName} completed *successfully* (<${BUILD_URL}>).\n\n\n${CUSTOM_SCM_INFO}",
webhookUrl: "https://outlook.office.com/webhook/97618564-835e-438e-a2a7-a77b21331e1e@22877e52-e9fd-410d-91a3-817d8ab89d63/JenkinsCI/fa736de2175649a891c2957f00532027/87d23462-1d0c-4378-b4e0-05c7d5546a25" webhookUrl: "https://outlook.office.com/webhook/97618564-835e-438e-a2a7-a77b21331e1e@22877e52-e9fd-410d-91a3-817d8ab89d63/JenkinsCI/fa736de2175649a891c2957f00532027/87d23462-1d0c-4378-b4e0-05c7d5546a25"

5
fh.fd.ci.server/src/main/java/de/fd/fh/server/access/Access.java

@ -43,4 +43,9 @@ public class Access
{ {
this.password = newPassword; this.password = newPassword;
} }
void rename(final String name)
{
this.name = name;
}
} }

7
fh.fd.ci.server/src/main/java/de/fd/fh/server/access/AccessService.java

@ -80,8 +80,6 @@ public class AccessService extends Observable
{ {
try try
{ {
System.out.println("logout " + header);
final Access access = accessRepository.findByToken(header.substring("Bearer ".length())); final Access access = accessRepository.findByToken(header.substring("Bearer ".length()));
access.removeToken(); access.removeToken();
@ -89,10 +87,9 @@ public class AccessService extends Observable
accessRepository.save(access); accessRepository.save(access);
return true; return true;
} catch (Exception e)
} catch (final Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} }
} }
@ -126,7 +123,7 @@ public class AccessService extends Observable
} }
return null; return null;
} catch (Exception e)
} catch (final Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
return null; return null;

48
fh.fd.ci.server/src/test/java/de/fd/fh/server/access/AccessTest.java

@ -0,0 +1,48 @@
package de.fd.fh.server.access;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class AccessTest
{
@Test
void removeTokenTest()
{
final Access access = new Access(null, null, null, null, new AccessToken(), null);
access.removeToken();
assertNull(access.getToken());
}
@Test
void setTokenTest()
{
final Access access = new Access();
access.setToken(new AccessToken());
assertNotNull(access.getToken());
}
@Test
void updatePasswordTest()
{
final Access access = new Access(null,null, "TestPassword", null, null, null);
access.updatePassword("NewTestPassword");
assertEquals("NewTestPassword", access.getPassword(), "Should update password.");
}
@Test
void renameTest()
{
final Access access = new Access(null, "TestName", null, null, null, null);
access.rename("NewTestName");
assertEquals("NewTestName", access.getName(), "Should update name.");
}
}
Loading…
Cancel
Save