@Test
 public void should_execute_on_javascript_project() {
   Project project = new Project("key");
   project.setLanguageKey("java");
   assertThat(sensor.shouldExecuteOnProject(project)).isFalse();
   project.setLanguageKey("js");
   assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
 }
  @Test
  public void should_analyse() {
    ProjectFileSystem fs = mock(ProjectFileSystem.class);
    when(fs.getSourceCharset()).thenReturn(Charset.forName("UTF-8"));
    InputFile inputFile =
        InputFileUtils.create(
            new File("src/test/resources/cpd"), new File("src/test/resources/cpd/Person.js"));
    when(fs.mainFiles(JavaScript.KEY)).thenReturn(ImmutableList.of(inputFile));
    Project project = new Project("key");
    project.setFileSystem(fs);
    SensorContext context = mock(SensorContext.class);

    sensor.analyse(project, context);

    verify(context)
        .saveMeasure(Mockito.any(Resource.class), Mockito.eq(CoreMetrics.FILES), Mockito.eq(1.0));
    verify(context)
        .saveMeasure(Mockito.any(Resource.class), Mockito.eq(CoreMetrics.LINES), Mockito.eq(22.0));
    verify(context)
        .saveMeasure(Mockito.any(Resource.class), Mockito.eq(CoreMetrics.NCLOC), Mockito.eq(10.0));
    verify(context)
        .saveMeasure(
            Mockito.any(Resource.class), Mockito.eq(CoreMetrics.FUNCTIONS), Mockito.eq(2.0));
    verify(context)
        .saveMeasure(
            Mockito.any(Resource.class), Mockito.eq(CoreMetrics.STATEMENTS), Mockito.eq(6.0));
    verify(context)
        .saveMeasure(
            Mockito.any(Resource.class), Mockito.eq(CoreMetrics.COMPLEXITY), Mockito.eq(3.0));
    verify(context)
        .saveMeasure(
            Mockito.any(Resource.class), Mockito.eq(CoreMetrics.COMMENT_LINES), Mockito.eq(2.0));
  }