Java 类org.junit.gen5.api.DisplayName 实例源码

项目:jdeps-wall-of-shame    文件:YamlPersisterTest.java   
@Test
@DisplayName("can dump and load resolved projects")
void persistResolvedProject() {
    ResolvedProject project = new ResolvedProject(
            ProjectCoordinates.from("project", "artifact"),
            of(
                    ArtifactCoordinates.from("project", "artifact", "v1"),
                    ArtifactCoordinates.from("project", "artifact", "v2"))
    );

    String artifactAsYaml = persister.writeResolvedProject(project);
    ResolvedProject loadedProject = persister.readResolvedProject(artifactAsYaml);

    assertThat(loadedProject).isEqualTo(project);
    // equality is based on coordinates so we have to check versions explicitly
    assertThat(loadedProject.versions()).isEqualTo(project.versions());
}
项目:jdeps-wall-of-shame    文件:YamlPersisterTest.java   
@Test
@DisplayName("can dump and load resolved artifacts")
void persistResolvedArtifact() {
    ResolvedArtifact artifact = new ResolvedArtifact(
            ArtifactCoordinates.from("artifact.group", "artifact", "version"),
            of(
                    ArtifactCoordinates.from("dependee1.group", "dep", "v1"),
                    ArtifactCoordinates.from("dependee2.group", "dependee", "v2"))
    );

    String artifactAsYaml = persister.writeResolvedArtifact(artifact);
    ResolvedArtifact loadedArtifact = persister.readResolvedArtifact(artifactAsYaml);

    assertThat(loadedArtifact).isEqualTo(artifact);
    // equality is based on coordinates so we have to check dependees explicitly
    assertThat(loadedArtifact.dependees()).isEqualTo(artifact.dependees());
}
项目:jdeps-wall-of-shame    文件:YamlPersisterTest.java   
@Test
@DisplayName("can dump and load analyzed artifacts")
void persistAnalyzedArtifact() {
    AnalyzedArtifact artifact = new AnalyzedArtifact(
            ArtifactCoordinates.from("artifact.group", "artifact", "version"),
            of(
                    Violation.buildFor(
                            Type.of("artifact.package", "Class"),
                            of(
                                    InternalType.of("sun.misc", "Unsafe", "internal", "JDK-internal"),
                                    InternalType.of("sun.misc", "BASE64Encoder", "internal", "JDK-internal"))),
                    Violation.buildFor(
                            Type.of("artifact.package", "Class"),
                            of(
                                    InternalType.of("sun.misc", "Unsafe", "internal", "JDK-internal"),
                                    InternalType.of("sun.misc", "BASE64Encoder", "internal", "JDK-internal"))))
    );

    String artifactAsYaml = persister.writeAnalyzedArtifact(artifact);
    AnalyzedArtifact loadedArtifact = persister.readAnalyzedArtifact(artifactAsYaml);

    assertThat(loadedArtifact).isEqualTo(artifact);
    // equality is based on coordinates so we have to check violations explicitly
    assertThat(loadedArtifact.violations()).isEqualTo(artifact.violations());
}
项目:spring-cloud-services-connector    文件:ConfigServerServiceInfoCreatorTest.java   
@Test
@DisplayName("Given a valid kubernetes service we provide a valid config service info")
public void testCreateServiceInfo() throws Exception {
    Service service = new Service();

    service.setMetadata(getObjectMeta());
    service.setSpec(getServiceSpec());

    ConfigServerServiceInfo serviceInfo = configServerServiceInfoCreator.createServiceInfo(service);
    assertNotNull(serviceInfo);
    assertEquals("http://config-service:8080/", serviceInfo.getUri());
}
项目:spring-cloud-services-connector    文件:ConfigServerServiceInfoCreatorTest.java   
@Test
@DisplayName("Given a kubernetes service without ports we launch a NPE")
public void testCreateServiceInfo_ServiceNoPorts() throws Exception {
    Service service = new Service();
    service.setMetadata(getObjectMeta());

    expectThrows(NullPointerException.class, () -> configServerServiceInfoCreator.createServiceInfo(service));
}
项目:spring-cloud-services-connector    文件:ConfigServerServiceInfoCreatorTest.java   
@Test
@DisplayName("Given a kubernetes service without metadata we launch a NPE")
public void testCreateServiceInfo_ServiceNoMetadata() throws Exception {

    Service service = new Service();
    service.setSpec(getServiceSpec());

    expectThrows(NullPointerException.class, () -> configServerServiceInfoCreator.createServiceInfo(service));
}
项目:spring-cloud-services-connector    文件:ConfigServerServiceInfoCreatorTest.java   
@Test
@DisplayName("Given the service file, when we instantiate the content then we get a KubernetesServiceInfoCreator")
public void testKubernetesServiceInfoCreatorFromServiceFile() throws Exception {
    InputStream resourceAsStream = this.getClass().getResourceAsStream(
            "/META-INF/services/org.springframework.cloud.kubernetes.connector.KubernetesServiceInfoCreator");
    byte[] bytes = new byte[resourceAsStream.available()];
    resourceAsStream.read(bytes);
    Class<?> aClass = Class.forName(new String(bytes));
    Object o = aClass.newInstance();
    assertTrue(o instanceof KubernetesServiceInfoCreator);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("with null channel, throws NPE")
void decoratedChannelNull_throwsException() {
    assertThatThrownBy(
            () -> new ReplayingTaskChannelDecorator<>(null, emptySet(), emptySet(), emptySet()))
            .isInstanceOf(NullPointerException.class)
            .hasMessageContaining("decoratedChannel");
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("with null task replay collection, throws NPE")
void tasksToReplayNull_throwsException() {
    assertThatThrownBy(
            () -> new ReplayingTaskChannelDecorator<>(decoratedChannel, null, emptySet(), emptySet()))
            .isInstanceOf(NullPointerException.class)
            .hasMessageContaining("tasksToReplay");
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("with null result replay collection, throws NPE")
void resultsToReplayNull_throwsException() {
    assertThatThrownBy(
            () -> new ReplayingTaskChannelDecorator<>(decoratedChannel, emptySet(), null, emptySet()))
            .isInstanceOf(NullPointerException.class)
            .hasMessageContaining("resultsToReplay");
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("with null error replay collection, throws NPE")
void errorsToReplayNull_throwsException() {
    assertThatThrownBy(
            () -> new ReplayingTaskChannelDecorator<>(decoratedChannel, emptySet(), emptySet(), null))
            .isInstanceOf(NullPointerException.class)
            .hasMessageContaining("errorsToReplay");
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("sends task to decorated channel")
void sendTask_decoratedChannelGetsCalled() {
    replayingChannel.sendTask("Task");
    verify(decoratedChannel).sendTask("Task");
    verifyNoMoreInteractions(decoratedChannel);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("gets task from decorated channel")
void getTask_decoratedChannelGetsCalled() throws InterruptedException {
    replayingChannel.getTask();
    verify(decoratedChannel).getTask();
    verifyNoMoreInteractions(decoratedChannel);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("sends result to decorated channel")
void sendResult_decoratedChannelGetsCalled() throws InterruptedException {
    replayingChannel.sendResult(5);
    verify(decoratedChannel).sendResult(5);
    verifyNoMoreInteractions(decoratedChannel);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("returns only results from decorated channel")
void drainResults_onlyFromDecoratedChannel() {
    List<Integer> decoratedResults = asList(1, 2, 3);

    when(decoratedChannel.drainResults()).thenReturn(decoratedResults.stream());
    assertThat(replayingChannel.drainResults()).containsExactlyElementsOf(decoratedResults);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("sends errors to decorated channel")
void sendError_decoratedChannelGetsCalled() throws InterruptedException {
    Exception error = new Exception();

    replayingChannel.sendError(error);

    verify(decoratedChannel).sendError(error);
    verifyNoMoreInteractions(decoratedChannel);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("returns only errors from decorated channel")
void drainErrors_onlyFromDecoratedChannel() {
    List<Exception> decoratedErrors = asList(
            new Exception("X"),
            new Exception("Y")
    );

    Stream<Exception> errors = decoratedChannel.drainErrors();

    when(errors).thenReturn(decoratedErrors.stream());
    assertThat(replayingChannel.drainErrors()).containsExactlyElementsOf(decoratedErrors);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("sends task to decorated channel")
void sendTask_decoratedChannelGetsCalled() {
    replayingChannel.sendTask("Task");
    verify(decoratedChannel).sendTask("Task");
    verifyNoMoreInteractions(decoratedChannel);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("gets tasks from replay, then from decorated channel")
void getTask_tasksGetReplayed() throws InterruptedException {
    List<String> decoratedTasks = of("X", "Y", "Z");
    OngoingStubbing<String> stubbingGetTask = when(decoratedChannel.getTask());
    for (String task : decoratedTasks)
        stubbingGetTask = stubbingGetTask.thenReturn(task);
    int taskTotal = tasksToReplay.size() + decoratedTasks.size();

    List<String> tasks = takeTimes(replayingChannel::getTask, taskTotal);

    assertThat(tasks).containsExactlyElementsOf(concat(tasksToReplay, decoratedTasks));
    verify(decoratedChannel, times(decoratedTasks.size())).getTask();
    verifyNoMoreInteractions(decoratedChannel);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("sends result to decorated channel")
void sendResult_decoratedChannelGetsCalled() throws InterruptedException {
    replayingChannel.sendResult(5);
    verify(decoratedChannel).sendResult(5);
    verifyNoMoreInteractions(decoratedChannel);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("gets results from replay, then from decorated channel")
void drainResults_resultsGetReplayed() {
    List<Integer> decoratedResults = asList(10, 20, 30);
    when(decoratedChannel.drainResults()).thenReturn(decoratedResults.stream());

    Stream<Integer> results = replayingChannel.drainResults();

    assertThat(results).containsExactlyElementsOf(concat(resultsToReplay, decoratedResults));
    verify(decoratedChannel).drainResults();
    verifyNoMoreInteractions(decoratedChannel);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("gets results from replay only once")
void drainResults_resultsGetReplayedOnce() {
    List<Integer> decoratedResults_1 = asList(10, 20, 30);
    List<Integer> decoratedResults_2 = asList(100, 200, 300);
    when(decoratedChannel.drainResults()).thenReturn(decoratedResults_1.stream(), decoratedResults_2.stream());

    // the first call should drain the replay and call the stubbed method for the first time
    replayingChannel.drainResults().forEach(ignored -> {
    });
    // the second call should return only the result from the stubbed method
    Stream<Integer> results = replayingChannel.drainResults();

    assertThat(results).containsExactlyElementsOf(decoratedResults_2);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("sends errors to decorated channel")
void sendError_decoratedChannelGetsCalled() throws InterruptedException {
    Exception error = new Exception();
    replayingChannel.sendError(error);

    verify(decoratedChannel).sendError(error);
    verifyNoMoreInteractions(decoratedChannel);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("gets errors from replay, then from decorated channel")
void drainErrors_errorsGetReplayed() {
    List<Exception> decoratedErrors = asList(new Exception("ABC"), new Exception("XYZ"));
    when(decoratedChannel.drainErrors()).thenReturn(decoratedErrors.stream());

    Stream<Exception> errors = replayingChannel.drainErrors();

    assertThat(errors).containsExactlyElementsOf(concat(errorsToReplay, decoratedErrors));
    verify(decoratedChannel).drainErrors();
    verifyNoMoreInteractions(decoratedChannel);
}
项目:jdeps-wall-of-shame    文件:ReplayingTaskChannelDecoratorTest.java   
@Test
@DisplayName("gets errors from replay only once")
void drainErrors_resultsGetReplayedOnce() {
    List<Exception> decoratedErrors_1 = asList(new Exception("A"), new Exception("X"));
    List<Exception> decoratedErrors_2 = asList(new Exception("ABC"), new Exception("XYZ"));
    when(decoratedChannel.drainErrors()).thenReturn(decoratedErrors_1.stream(), decoratedErrors_2.stream());

    // the first call should drain the replay and call the stubbed method for the first time
    replayingChannel.drainErrors().forEach(ignored -> {
    });
    // the second call should return only the result from the stubbed method
    Stream<Exception> results = replayingChannel.drainErrors();

    assertThat(results).containsExactlyElementsOf(decoratedErrors_2);
}
项目:jdeps-wall-of-shame    文件:SpyingTaskChannelDecoratorTest.java   
@Test
@DisplayName("with null decorated channel, throws NPE")
void decoratedChannelNull_throwsException() {
    assertThatThrownBy(
            () -> new SpyingTaskChannelDecorator<>(null, listeningChannel))
            .isInstanceOf(NullPointerException.class)
            .hasMessageContaining("decoratedChannel");
}
项目:jdeps-wall-of-shame    文件:SpyingTaskChannelDecoratorTest.java   
@Test
@DisplayName("with null listening channel, throws NPE")
void listeningChannelNull_throwsException() {
    assertThatThrownBy(
            () -> new SpyingTaskChannelDecorator<>(decoratedChannel, null))
            .isInstanceOf(NullPointerException.class)
            .hasMessageContaining("listeningChannel");
}
项目:jdeps-wall-of-shame    文件:SpyingTaskChannelDecoratorTest.java   
@Test
@DisplayName("tasks")
void sendTask_taskGetsRelayed() {
    spyingChannel.sendTask("X");

    verify(decoratedChannel).sendTask("X");
    verify(listeningChannel).sendTask("X");
    verifyNoMoreInteractions(decoratedChannel, listeningChannel);
}
项目:jdeps-wall-of-shame    文件:SpyingTaskChannelDecoratorTest.java   
@Test
@DisplayName("results")
void sendResult_resultGetsRelayed() throws InterruptedException {
    spyingChannel.sendResult(1);

    verify(decoratedChannel).sendResult(1);
    verify(listeningChannel).sendResult(1);
    verifyNoMoreInteractions(decoratedChannel, listeningChannel);
}
项目:jdeps-wall-of-shame    文件:SpyingTaskChannelDecoratorTest.java   
@Test
@DisplayName("errors")
void sendError_errorGetsRelayed() throws InterruptedException {
    Exception error = new Exception("ABC");
    spyingChannel.sendError(error);

    verify(decoratedChannel).sendError(error);
    verify(listeningChannel).sendError(error);
    verifyNoMoreInteractions(decoratedChannel, listeningChannel);
}
项目:jdeps-wall-of-shame    文件:SpyingTaskChannelDecoratorTest.java   
@Test
@DisplayName("tasks")
void getTask_callIsDelegated() throws InterruptedException {
    spyingChannel.getTask();

    verify(decoratedChannel).getTask();
    verifyNoMoreInteractions(decoratedChannel, listeningChannel);
}
项目:jdeps-wall-of-shame    文件:SpyingTaskChannelDecoratorTest.java   
@Test
@DisplayName("results")
void sendResult_resultGetsRelayed() throws InterruptedException {
    spyingChannel.drainResults();

    verify(decoratedChannel).drainResults();
    verifyNoMoreInteractions(decoratedChannel, listeningChannel);
}
项目:jdeps-wall-of-shame    文件:SpyingTaskChannelDecoratorTest.java   
@Test
@DisplayName("errors")
void sendError_errorGetsRelayed() throws InterruptedException {
    spyingChannel.drainErrors();

    verify(decoratedChannel).drainErrors();
    verifyNoMoreInteractions(decoratedChannel, listeningChannel);
}
项目:jdeps-wall-of-shame    文件:YamlPersisterTest.java   
@Test
@DisplayName("can dump and load projects")
void persistProject() {
    ProjectCoordinates project = ProjectCoordinates.from("org.group", "theProject");

    String projectAsYaml = persister.writeProject(project);
    ProjectCoordinates loadedProject = persister.readProject(projectAsYaml);

    assertThat(loadedProject).isEqualTo(project);
}
项目:jdeps-wall-of-shame    文件:YamlPersisterTest.java   
@Test
@DisplayName("can dump and load failed projects")
void persistFailedProject() {
    FailedProject project = new FailedProject(
            ProjectCoordinates.from("org.group", "theProject"),
            new Exception("error message")
    );

    String projectAsYaml = persister.writeFailedProject(project);
    FailedProject loadedProject = persister.readFailedProject(projectAsYaml);

    assertThat(loadedProject).isEqualTo(project);
}
项目:jdeps-wall-of-shame    文件:YamlPersisterTest.java   
@Test
@DisplayName("can dump and load artifacts")
void persistArtifact() {
    ArtifactCoordinates artifact = ArtifactCoordinates.from("org.group", "theArtifact", "v1.Foo");

    String artifactAsYaml = persister.writeArtifact(artifact);
    ArtifactCoordinates loadedArtifact = persister.readArtifact(artifactAsYaml);

    assertThat(loadedArtifact).isEqualTo(artifact);
}
项目:jdeps-wall-of-shame    文件:YamlPersisterTest.java   
@Test
@DisplayName("can dump and load failed artifacts")
void persistFailedArtifact() {
    FailedArtifact artifact = new FailedArtifact(
            ArtifactCoordinates.from("org.group", "theArtifact", "v1.Foo"),
            new Exception("error message")
    );

    String artifactAsYaml = persister.writeFailedArtifact(artifact);
    FailedArtifact loadedArtifact = persister.readFailedArtifact(artifactAsYaml);

    assertThat(loadedArtifact).isEqualTo(artifact);
}
项目:evilmusic    文件:PlaylistRESTTest.java   
@Test
@DisplayName("removes an element from the playlist")
void removesElement() throws IOException {
    p = PlaylistRESTCalls.removeElement(p.getID(), e0.getID());

    assertEquals(2, p.size());
    assertEquals(e1.getID(), p.getElement(0).getID());
    assertEquals(e2.getID(), p.getElement(1).getID());
}
项目:evilmusic    文件:LibraryUtilsTest.java   
@Test
@DisplayName("will correctly convert a music directory string containing the $home keyword to a file")
void homeKeyword() throws URISyntaxException {
    final String home = System.getProperty("user.home");
    final String sep = File.separator;

    assertNull(LibraryUtils.convertToFile(""));
    assertNull(LibraryUtils.convertToFile(null));
    assertEquals(home + sep + "docs", LibraryUtils.convertToFile("$home" + sep + "docs").getPath());
    assertEquals("foo" + sep + "bar", LibraryUtils.convertToFile("foo" + sep + "bar").getPath());
}
项目:evilmusic    文件:LibraryUtilsTest.java   
@Test
@DisplayName("will correctly convert a music directory string containing a $timestamp keyword to a file")
void timestampKeyword() throws ParseException, URISyntaxException {
    final String sep = File.separator;
    final String prefix = sep + "foo" + sep;
    final String suffix = "bar";
    final File f = LibraryUtils.convertToFile(prefix + "$timestamp" + suffix);
    final String path = f.getPath();

    assertThat(path, new ContainsRecentTimestamp(prefix.length(), path.length() - suffix.length()));
}