|
5 | 5 | import ml.comet.experiment.OnlineExperiment; |
6 | 6 | import ml.comet.experiment.asset.LoggedExperimentAsset; |
7 | 7 | import ml.comet.experiment.context.ExperimentContext; |
| 8 | +import ml.comet.experiment.exception.CometGeneralException; |
8 | 9 | import ml.comet.experiment.model.ExperimentMetadata; |
9 | 10 | import ml.comet.experiment.model.GitMetaData; |
10 | 11 | import ml.comet.experiment.model.Value; |
11 | 12 | import org.apache.commons.lang3.StringUtils; |
12 | 13 | import org.junit.jupiter.api.DisplayName; |
13 | 14 | import org.junit.jupiter.api.Tag; |
14 | 15 | import org.junit.jupiter.api.Test; |
| 16 | +import org.junit.jupiter.api.Timeout; |
15 | 17 |
|
16 | 18 | import java.time.Instant; |
17 | 19 | import java.util.HashMap; |
|
26 | 28 | import static ml.comet.experiment.impl.TestUtils.SOME_FULL_CONTEXT; |
27 | 29 | import static ml.comet.experiment.impl.TestUtils.awaitForCondition; |
28 | 30 | import static ml.comet.experiment.impl.asset.AssetType.SOURCE_CODE; |
| 31 | +import static ml.comet.experiment.impl.resources.LogMessages.FAILED_REGISTER_EXPERIMENT; |
| 32 | +import static ml.comet.experiment.impl.resources.LogMessages.getString; |
29 | 33 | import static ml.comet.experiment.impl.utils.CometUtils.fullMetricName; |
30 | 34 | import static org.junit.jupiter.api.Assertions.assertEquals; |
31 | 35 | import static org.junit.jupiter.api.Assertions.assertFalse; |
32 | 36 | import static org.junit.jupiter.api.Assertions.assertNotEquals; |
33 | 37 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
34 | 38 | import static org.junit.jupiter.api.Assertions.assertNull; |
| 39 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
35 | 40 | import static org.junit.jupiter.api.Assertions.assertTrue; |
36 | 41 | import static org.junit.jupiter.api.Assertions.fail; |
37 | 42 |
|
@@ -506,6 +511,15 @@ public void testLogAndGetRawCode() { |
506 | 511 | } |
507 | 512 | } |
508 | 513 |
|
| 514 | + @Test |
| 515 | + @Timeout(60) |
| 516 | + public void testCreateExperiment_wrongApiKey() { |
| 517 | + String wrongApiKey = "not existing API key"; |
| 518 | + CometGeneralException ex = assertThrows(CometGeneralException.class, () -> |
| 519 | + OnlineExperimentImpl.builder().withApiKey(wrongApiKey).build()); |
| 520 | + assertEquals(getString(FAILED_REGISTER_EXPERIMENT), ex.getMessage()); |
| 521 | + } |
| 522 | + |
509 | 523 | static final class OnCompleteAction implements Action, BooleanSupplier { |
510 | 524 | boolean completed; |
511 | 525 |
|
|
0 commit comments