-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/test/java/de/tum/cit/aet/artemis/core/config/LicenseConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package de.tum.cit.aet.artemis.core.config; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class LicenseConfigurationTest { | ||
|
||
@Test | ||
void testMatlabLicenseServer() { | ||
String licenseServer = "1234@license-server"; | ||
LicenseConfiguration licenseConfiguration = new LicenseConfiguration(new LicenseConfiguration.MatLabLicense(licenseServer)); | ||
assertThat(licenseConfiguration.getMatlabLicenseServer()).isEqualTo(licenseServer); | ||
} | ||
|
||
@Test | ||
void testMatlabNullRecord() { | ||
LicenseConfiguration licenseConfiguration = new LicenseConfiguration(null); | ||
assertThat(licenseConfiguration.getMatlabLicenseServer()).isNull(); | ||
} | ||
|
||
@Test | ||
void testMatlabNullValue() { | ||
LicenseConfiguration licenseConfiguration = new LicenseConfiguration(new LicenseConfiguration.MatLabLicense(null)); | ||
assertThat(licenseConfiguration.getMatlabLicenseServer()).isNull(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/test/java/de/tum/cit/aet/artemis/programming/service/LicenseServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package de.tum.cit.aet.artemis.programming.service; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.Map; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import de.tum.cit.aet.artemis.core.config.LicenseConfiguration; | ||
import de.tum.cit.aet.artemis.programming.domain.ProgrammingLanguage; | ||
import de.tum.cit.aet.artemis.programming.domain.ProjectType; | ||
import de.tum.cit.aet.artemis.shared.base.AbstractSpringIntegrationIndependentTest; | ||
|
||
class LicenseServiceTest extends AbstractSpringIntegrationIndependentTest { | ||
|
||
@Autowired | ||
private LicenseService licenseService; | ||
|
||
@Test | ||
void testIsLicensedNoneRequired() { | ||
boolean isLicensed = licenseService.isLicensed(ProgrammingLanguage.JAVA, ProjectType.GRADLE_GRADLE); | ||
assertThat(isLicensed).isTrue(); | ||
} | ||
|
||
@Test | ||
void testGetLicenseNoneRequired() { | ||
Map<String, String> environment = licenseService.getEnvironment(ProgrammingLanguage.JAVA, ProjectType.GRADLE_GRADLE); | ||
assertThat(environment).isEmpty(); | ||
} | ||
|
||
@Test | ||
void testIsLicensedMatlab() { | ||
boolean isLicensed = licenseService.isLicensed(ProgrammingLanguage.MATLAB, null); | ||
assertThat(isLicensed).isTrue(); | ||
} | ||
|
||
@Test | ||
void testGetLicenseMatlab() { | ||
Map<String, String> environment = licenseService.getEnvironment(ProgrammingLanguage.MATLAB, null); | ||
assertThat(environment).containsEntry("MLM_LICENSE_FILE", "1234@license-server"); | ||
} | ||
|
||
@Test | ||
void testIsLicensedMatlabUnlicensed() { | ||
LicenseConfiguration licenseConfiguration = new LicenseConfiguration(null); | ||
LicenseService licenseService = new LicenseService(licenseConfiguration); | ||
boolean isLicensed = licenseService.isLicensed(ProgrammingLanguage.MATLAB, null); | ||
assertThat(isLicensed).isFalse(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters