@@ -0,0 +1,2729 @@
+/*%0A * Copyright 2016-present Facebook, Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22); you may%0A * not use this file except in compliance with the License. You may obtain%0A * a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A * License for the specific language governing permissions and limitations%0A * under the License.%0A */%0A%0Apackage com.facebook.buck.parser;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0A%0Aimport com.facebook.buck.cli.BuckConfig;%0Aimport com.facebook.buck.cli.FakeBuckConfig;%0Aimport com.facebook.buck.io.ProjectFilesystem;%0Aimport com.facebook.buck.model.BuildTarget;%0Aimport com.facebook.buck.model.BuildTargetException;%0Aimport com.facebook.buck.model.BuildTargetFactory;%0Aimport com.facebook.buck.parser.PipelineNodeCache.Cache;%0Aimport com.facebook.buck.rules.Cell;%0Aimport com.facebook.buck.rules.TestCellBuilder;%0Aimport com.facebook.buck.testutil.integration.TemporaryPaths;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0A%0Aimport java.io.IOException;%0Aimport java.nio.file.Path;%0Aimport java.util.Optional;%0A%0Apublic class DaemonicCellStateTest %7B%0A%0A  @Rule%0A  public TemporaryPaths tempDir = new TemporaryPaths();%0A%0A  private ProjectFilesystem filesystem;%0A  private Cell cell;%0A  private DaemonicCellState state;%0A%0A  @Before%0A  public void setUp() throws IOException, InterruptedException %7B%0A    Path root = tempDir.getRoot().toRealPath();%0A    filesystem = new ProjectFilesystem(root);%0A    BuckConfig config = FakeBuckConfig.builder()%0A        .setFilesystem(filesystem)%0A        .build();%0A    cell = new TestCellBuilder()%0A        .setFilesystem(filesystem)%0A        .setBuckConfig(config)%0A        .build();%0A    state = new DaemonicCellState(cell, 1);%0A  %7D%0A%0A  @Test%0A  public void testPutComputedNodeIfNotPresent()%0A      throws BuildTargetException, IOException, InterruptedException %7B%0A    Cache%3CBuildTarget, Boolean%3E cache = state.getOrCreateCache(Boolean.class);%0A    BuildTarget target = BuildTargetFactory.newInstance(filesystem, %22//path/to:target%22);%0A%0A    cache.putComputedNodeIfNotPresent(cell, target, false);%0A    assertEquals(%0A        %22Cached node was not found%22,%0A        Optional.of(false),%0A        cache.lookupComputedNode(cell, target));%0A%0A    assertFalse(cache.putComputedNodeIfNotPresent(cell, target, true));%0A    assertEquals(%0A        %22Previously cached node should not be updated%22,%0A        Optional.of(false),%0A        cache.lookupComputedNode(cell, target));%0A  %7D%0A%0A%7D%0A

Add some unit tests for DaemonicCellState