### Question:
CHAlgoFactoryDecorator implements RoutingAlgorithmFactoryDecorator { public CHAlgoFactoryDecorator addPreparation(PrepareContractionHierarchies pch) { if (preparations.size() >= chProfiles.size()) { throw new IllegalStateException("You need to add the corresponding CH profiles before adding preparations."); } CHProfile expectedProfile = chProfiles.get(preparations.size()); if (!pch.getCHProfile().equals(expectedProfile)) { throw new IllegalArgumentException("CH profile of preparation: " + pch + " needs to be identical to previously added CH profile: " + expectedProfile); } preparations.add(pch); return this; } CHAlgoFactoryDecorator(); @Override void init(GraphHopperConfig ghConfig); @Override final boolean isEnabled(); final CHAlgoFactoryDecorator setEnabled(boolean enabled); final boolean isDisablingAllowed(); final CHAlgoFactoryDecorator setDisablingAllowed(boolean disablingAllowed); final CHAlgoFactoryDecorator setEdgeBasedCHMode(EdgeBasedCHMode edgeBasedCHMode); CHAlgoFactoryDecorator addCHProfile(CHProfile chProfile); CHAlgoFactoryDecorator addPreparation(PrepareContractionHierarchies pch); final boolean hasCHProfiles(); List<CHProfile> getCHProfiles(); List<CHProfile> getNodeBasedCHProfiles(); List<CHProfile> getEdgeBasedCHProfiles(); EdgeBasedCHMode getEdgeBasedCHMode(); List<String> getCHProfileStrings(); CHAlgoFactoryDecorator setCHProfileStrings(String... profileStrings); CHAlgoFactoryDecorator setCHProfilesAsStrings(List<String> profileStrings); CHAlgoFactoryDecorator addCHProfileAsString(String profileString); List<PrepareContractionHierarchies> getPreparations(); @Override RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFactory defaultAlgoFactory, HintsMap map); PrepareContractionHierarchies getPreparation(HintsMap map); PrepareContractionHierarchies getPreparation(CHProfile chProfile); int getPreparationThreads(); void setPreparationThreads(int preparationThreads); void prepare(final StorableProperties properties, final boolean closeEarly); void createPreparations(GraphHopperStorage ghStorage);  }### Answer:
@Test(expected = IllegalStateException.class) public void testAddingPreparationBeforeProfile_throws() { PrepareContractionHierarchies preparation = createPreparation(profileNode1); instance.addPreparation(preparation); }