Search in sources :

Example 1 with MaterialRegistryFixture

use of slimeknights.tconstruct.fixture.MaterialRegistryFixture in project TinkersConstruct by SlimeKnights.

the class MaterialRegistryExtension method beforeEach.

@Override
public void beforeEach(ExtensionContext context) {
    Map<IMaterial, List<IMaterialStats>> materialSetup = MaterialFixture.ALL_MATERIAL_FIXTURES;
    Map<MaterialId, IMaterial> materials = materialSetup.keySet().stream().collect(Collectors.toMap(IMaterial::getIdentifier, Function.identity()));
    Map<MaterialId, Map<MaterialStatsId, IMaterialStats>> stats = materialSetup.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey().getIdentifier(), entry -> entry.getValue().stream().collect(Collectors.toMap(IMaterialStats::getIdentifier, Function.identity()))));
    Map<MaterialStatsId, IMaterialStats> defaultStats = MaterialStatsFixture.TIC_DEFAULT_STATS.stream().collect(Collectors.toMap(IMaterialStats::getIdentifier, Function.identity()));
    // empty map as nothing using the extension uses traits
    materialRegistry = new MaterialRegistryFixture(materials, stats, defaultStats, Collections.emptyMap());
    MaterialRegistry.INSTANCE = new MaterialRegistry(materialRegistry);
}
Also used : MaterialStatsId(slimeknights.tconstruct.library.materials.stats.MaterialStatsId) MaterialFixture(slimeknights.tconstruct.fixture.MaterialFixture) ParameterResolutionException(org.junit.jupiter.api.extension.ParameterResolutionException) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) ParameterContext(org.junit.jupiter.api.extension.ParameterContext) MaterialRegistryFixture(slimeknights.tconstruct.fixture.MaterialRegistryFixture) List(java.util.List) MaterialId(slimeknights.tconstruct.library.materials.definition.MaterialId) AfterAllCallback(org.junit.jupiter.api.extension.AfterAllCallback) Map(java.util.Map) BeforeEachCallback(org.junit.jupiter.api.extension.BeforeEachCallback) IMaterialStats(slimeknights.tconstruct.library.materials.stats.IMaterialStats) ParameterResolver(org.junit.jupiter.api.extension.ParameterResolver) MaterialStatsFixture(slimeknights.tconstruct.fixture.MaterialStatsFixture) Collections(java.util.Collections) IMaterial(slimeknights.tconstruct.library.materials.definition.IMaterial) Mockito.mock(org.mockito.Mockito.mock) IMaterial(slimeknights.tconstruct.library.materials.definition.IMaterial) MaterialId(slimeknights.tconstruct.library.materials.definition.MaterialId) MaterialRegistryFixture(slimeknights.tconstruct.fixture.MaterialRegistryFixture) MaterialStatsId(slimeknights.tconstruct.library.materials.stats.MaterialStatsId) IMaterialStats(slimeknights.tconstruct.library.materials.stats.IMaterialStats) List(java.util.List) Map(java.util.Map)

Aggregations

Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 AfterAllCallback (org.junit.jupiter.api.extension.AfterAllCallback)1 BeforeEachCallback (org.junit.jupiter.api.extension.BeforeEachCallback)1 ExtensionContext (org.junit.jupiter.api.extension.ExtensionContext)1 ParameterContext (org.junit.jupiter.api.extension.ParameterContext)1 ParameterResolutionException (org.junit.jupiter.api.extension.ParameterResolutionException)1 ParameterResolver (org.junit.jupiter.api.extension.ParameterResolver)1 Mockito.mock (org.mockito.Mockito.mock)1 MaterialFixture (slimeknights.tconstruct.fixture.MaterialFixture)1 MaterialRegistryFixture (slimeknights.tconstruct.fixture.MaterialRegistryFixture)1 MaterialStatsFixture (slimeknights.tconstruct.fixture.MaterialStatsFixture)1 IMaterial (slimeknights.tconstruct.library.materials.definition.IMaterial)1 MaterialId (slimeknights.tconstruct.library.materials.definition.MaterialId)1 IMaterialStats (slimeknights.tconstruct.library.materials.stats.IMaterialStats)1 MaterialStatsId (slimeknights.tconstruct.library.materials.stats.MaterialStatsId)1