Skip to content

Commit

Permalink
doc: show 6 for V6 Engines in docs (#7600)
Browse files Browse the repository at this point in the history
Close #7590
  • Loading branch information
sdelamo authored and dstepanov committed Jul 8, 2022
1 parent 7663af0 commit c0cc1e8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package io.micronaut.docs.inject.generics
// tag::class[]
class V6 implements CylinderProvider {
@Override
int getCylinders() { 7 }
int getCylinders() { 6 }
}
// end::class[]
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ class VehicleSpec extends Specification {
void 'test start engine'() {
expect:
vehicle.start() == 'Starting V8'
[6] == vehicle.v6Engines.collect {engine -> engine.cylinders }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package io.micronaut.docs.inject.generics

// tag::class[]
class V6 : CylinderProvider {
override val cylinders: Int = 7
override val cylinders: Int = 6
}
// end::class[]
// end::class[]
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ class VehicleSpec(private val vehicle: Vehicle) {
@Test
fun testStartVehicle() {
assertEquals("Starting V8", vehicle.start())
assertEquals(listOf(6), vehicle.v6Engines
.map { it.cylinders })
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
public class V6 implements CylinderProvider {
@Override
public int getCylinders() {
return 7;
return 6;
}
}
// end::class[]
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.stream.Collectors;

import static org.junit.jupiter.api.Assertions.assertEquals;


Expand All @@ -16,6 +20,10 @@ public VehicleSpec(Vehicle vehicle) {
@Test
public void testStartVehicle() {
assertEquals("Starting V8", vehicle.start());
assertEquals(Collections.singletonList(6), vehicle.v6Engines
.stream()
.map(Engine::getCylinders)
.collect(Collectors.toList()));
}

}
}

0 comments on commit c0cc1e8

Please sign in to comment.