Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mjunkin committed Sep 6, 2024
1 parent 8870cc6 commit cda811e
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package ca.bc.gov.nrs.vdyp.common.controlmap;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;

import java.io.IOException;
import java.nio.file.Path;
import java.util.Map;

import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ca.bc.gov.nrs.vdyp.controlmap.CachingResolvedControlMapImpl;
import ca.bc.gov.nrs.vdyp.io.parse.common.ResourceParseException;
import ca.bc.gov.nrs.vdyp.model.BecLookup;
import ca.bc.gov.nrs.vdyp.model.GenusDefinitionMap;
import ca.bc.gov.nrs.vdyp.model.MatrixMap2;
import ca.bc.gov.nrs.vdyp.model.MatrixMap3;
import ca.bc.gov.nrs.vdyp.test.TestUtils;

public class ResolvedControlMapTest {

private static final Logger logger = LoggerFactory.getLogger(ResolvedControlMapTest.class);

@Test
void testCachingResolvedControlMap() throws IOException, ResourceParseException {
logger.info(this.getClass().getName() + ":testCachingResolvedControlMap running...");

var rawControlMap = TestUtils.loadControlMap(Path.of("VDYP.CTR"));

var cachingControlMap = new CachingResolvedControlMapImpl(rawControlMap);

assertThat(cachingControlMap.getControlMap(), is(rawControlMap));

Object e;
e = cachingControlMap.getBecLookup();
assertThat(e, instanceOf(BecLookup.class));
e = cachingControlMap.getGenusDefinitionMap();
assertThat(e, instanceOf(GenusDefinitionMap.class));
e = cachingControlMap.getNetDecayWasteCoeMap();
assertThat(e, instanceOf(Map.class));
e = cachingControlMap.getNetDecayCoeMap();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getWasteModifierMap();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getDecayModifierMap();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getCloseUtilizationCoeMap();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getTotalStandWholeStepVolumeCoeMap();
assertThat(e, instanceOf(Map.class));
e = cachingControlMap.getWholeStemUtilizationComponentMap();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getQuadMeanDiameterUtilizationComponentMap();
assertThat(e, instanceOf(MatrixMap3.class));
e = cachingControlMap.getBasalAreaDiameterUtilizationComponentMap();
assertThat(e, instanceOf(MatrixMap3.class));
e = cachingControlMap.getSmallComponentWholeStemVolumeCoefficients();
assertThat(e, instanceOf(Map.class));
e = cachingControlMap.getSmallComponentLoreyHeightCoefficients();
assertThat(e, instanceOf(Map.class));
e = cachingControlMap.getSmallComponentQuadMeanDiameterCoefficients();
assertThat(e, instanceOf(Map.class));
e = cachingControlMap.getSmallComponentBasalAreaCoefficients();
assertThat(e, instanceOf(Map.class));
e = cachingControlMap.getSmallComponentProbabilityCoefficients();
assertThat(e, instanceOf(Map.class));
e = cachingControlMap.getMaximumAgeBySiteCurveNumber();
assertThat(e, instanceOf(Map.class));
e = cachingControlMap.getUpperBounds();
assertThat(e, instanceOf(Map.class));
e = cachingControlMap.getDefaultEquationGroup();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getEquationModifierGroup();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getHl1Coefficients();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getHl2Coefficients();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getHl3Coefficients();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getHlNonPrimaryCoefficients();
assertThat(e, instanceOf(MatrixMap3.class));
e = cachingControlMap.getComponentSizeLimits();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getNetBreakageMap();
assertThat(e, instanceOf(Map.class));
e = cachingControlMap.getVolumeEquationGroups();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getDecayEquationGroups();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getBreakageEquationGroups();
assertThat(e, instanceOf(MatrixMap2.class));
e = cachingControlMap.getQuadMeanDiameterBySpeciesCoefficients();
assertThat(e, instanceOf(Map.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void testZipOutputFileResolver() throws IOException {
assertThrows(UnsupportedOperationException.class, () -> resolver.resolveForInput("file"));

MatcherAssert.assertThat(
resolver.toString("file"), Matchers.is("zip:/Users/mjunkin/source/vdyp-ssh/vdyp-lib/vdyp-common/file")
resolver.toString("file"), Matchers.endsWith("vdyp-lib/vdyp-common/file")
);

for (int i = 0; i < 5; i++) {
Expand Down

0 comments on commit cda811e

Please sign in to comment.