@Test
  public void testSortByKeywordLength() {
    final SolrURIRedirectModel redir = new SolrURIRedirectModel();

    final List<Comparator<SolrFacetSearchKeywordRedirectModel>> comparatorList =
        new ArrayList<Comparator<SolrFacetSearchKeywordRedirectModel>>();
    comparatorList.add(new KeywordLengthComparator());
    defaultKeywordRedirectSorter.setComparatorList(comparatorList);

    final List<SolrFacetSearchKeywordRedirectModel> toSort =
        new ArrayList<SolrFacetSearchKeywordRedirectModel>();
    final SolrFacetSearchKeywordRedirectModel val1 =
        createKeywordRedirect("jean", KeywordRedirectMatchType.CONTAINS, redir);
    final SolrFacetSearchKeywordRedirectModel val2 =
        createKeywordRedirect("jeans", KeywordRedirectMatchType.CONTAINS, redir);
    final SolrFacetSearchKeywordRedirectModel val3 =
        createKeywordRedirect("je", KeywordRedirectMatchType.EXACT, redir);
    final SolrFacetSearchKeywordRedirectModel val4 =
        createKeywordRedirect("jea", KeywordRedirectMatchType.EXACT, redir);

    toSort.add(val1);
    toSort.add(val2);
    toSort.add(val3);
    toSort.add(val4);

    Assertions.assertThat(toSort).containsSequence(val1, val2, val3, val4);

    final List<SolrFacetSearchKeywordRedirectModel> result =
        defaultKeywordRedirectSorter.sort(toSort);

    Assertions.assertThat(result).containsSequence(val4, val3, val2, val1);
  }
  @Test
  public void testDefaultActionListeners() {
    AbstractCommandButton expandButton1 =
        GuiActionRunner.execute(
            new GuiQuery<AbstractCommandButton>() {
              @Override
              protected AbstractCommandButton executeInEDT() throws Throwable {
                return ((BasicRibbonBandUI) ribbonBand1.getUI()).getExpandButton();
              }
            });
    robot().waitForIdle();

    Assertions.assertThat(expandButton1).isNull();

    AbstractCommandButton expandButton2 =
        GuiActionRunner.execute(
            new GuiQuery<AbstractCommandButton>() {
              @Override
              protected AbstractCommandButton executeInEDT() throws Throwable {
                return ((BasicRibbonBandUI) ribbonBand2.getUI()).getExpandButton();
              }
            });
    robot().waitForIdle();

    Assertions.assertThat(expandButton2).isNotNull();

    robot().click(expandButton2);
    robot().waitForIdle();

    Assertions.assertThat(count1).isEqualTo(1);
    Assertions.assertThat(count2).isZero();
  }
  /** Test method for {@link DefaultKeywordRedirectSorter#sort(List)}. */
  @Test
  public void testSort() {
    final SolrURIRedirectModel redir = new SolrURIRedirectModel();

    final List<SolrFacetSearchKeywordRedirectModel> toSort =
        new ArrayList<SolrFacetSearchKeywordRedirectModel>();
    final SolrFacetSearchKeywordRedirectModel val1 =
        createKeywordRedirect("Ala", KeywordRedirectMatchType.CONTAINS, redir);
    final SolrFacetSearchKeywordRedirectModel val2 =
        createKeywordRedirect("Ala", KeywordRedirectMatchType.ENDS_WITH, redir);
    final SolrFacetSearchKeywordRedirectModel val3 =
        createKeywordRedirect("Ala", KeywordRedirectMatchType.STARTS_WITH, redir);
    final SolrFacetSearchKeywordRedirectModel val4 =
        createKeywordRedirect("Ala", KeywordRedirectMatchType.REGEX, redir);
    final SolrFacetSearchKeywordRedirectModel val5 =
        createKeywordRedirect("Ala", KeywordRedirectMatchType.EXACT, redir);

    toSort.add(val1);
    toSort.add(val2);
    toSort.add(val3);
    toSort.add(val4);
    toSort.add(val5);

    Assertions.assertThat(toSort).containsSequence(val1, val2, val3, val4, val5);

    final List<SolrFacetSearchKeywordRedirectModel> result =
        defaultKeywordRedirectSorter.sort(toSort);

    Assertions.assertThat(result).containsSequence(val5, val4, val3, val2, val1);
  }
  @Test
  public void test_should_execute_on_project() {
    DefaultFileSystem fs = new DefaultFileSystem();
    CoberturaSensor sensor = new CoberturaSensor(new Settings(), fs);

    // No Flex file in file system
    Assertions.assertThat(sensor.shouldExecuteOnProject(project)).isFalse();

    // With Flex source file
    fs.add(new DefaultInputFile("Dummy.as").setLanguage(Flex.KEY).setType(InputFile.Type.MAIN));
    Assertions.assertThat(sensor.shouldExecuteOnProject(project)).isTrue();
  }
 protected static void assertQueryPromiseFailedWithCodes(
     Promise<QueryResponse, ResourceException> promise,
     int resourceErrorCode,
     int entitlementErrorCode) {
   try {
     promise.getOrThrowUninterruptibly();
     fail("Should throw ResourceException");
   } catch (ResourceException e) {
     Assertions.assertThat(e.getCode()).isEqualTo(resourceErrorCode);
     Assertions.assertThat(e.getCause()).isInstanceOf(EntitlementException.class);
     Assertions.assertThat(((EntitlementException) e.getCause()).getErrorCode())
         .isEqualTo(entitlementErrorCode);
   }
 }
  @Test
  public void testIfAggregatedStatisticsAreSavedToDb() {
    // given
    final Date date1 =
        new DateTime()
            .withYear(2011)
            .withMonthOfYear(10)
            .withDayOfMonth(15)
            .withHourOfDay(12)
            .withMinuteOfHour(20)
            .toDate();
    final Date date2 =
        new DateTime()
            .withYear(2011)
            .withMonthOfYear(10)
            .withDayOfMonth(15)
            .withHourOfDay(12)
            .withMinuteOfHour(45)
            .toDate();
    final Date date3 =
        new DateTime()
            .withYear(2011)
            .withMonthOfYear(11)
            .withDayOfMonth(19)
            .withHourOfDay(12)
            .withMinuteOfHour(45)
            .toDate();
    final List<AggregatedSearchQueryInfo> aggrResults = new ArrayList<AggregatedSearchQueryInfo>();
    aggrResults.add(new AggregatedSearchQueryInfo(SOLR_CONFIG_NAME, "monitor", "en", 5, date1));
    aggrResults.add(new AggregatedSearchQueryInfo(SOLR_CONFIG_NAME, "monitor lcd", "en", 3, date2));
    aggrResults.add(new AggregatedSearchQueryInfo(SOLR_CONFIG_NAME, "canon", "en", 2, date3));

    Mockito.when(mockSolrQueryStatisticsAggregator.aggregate()).thenReturn(aggrResults);

    solrQueryStatisticsCollectorJob.setSolrQueryStatisticsAggregator(
        mockSolrQueryStatisticsAggregator);

    // when
    final PerformResult perform = solrQueryStatisticsCollectorJob.perform(null);

    // then
    org.fest.assertions.Assertions.assertThat(perform.getResult()).isEqualTo(CronJobResult.SUCCESS);
    org.fest.assertions.Assertions.assertThat(perform.getStatus())
        .isEqualTo(CronJobStatus.FINISHED);

    final SearchResult<SolrQueryAggregatedStatsModel> result =
        flexibleSearchService.search("SELECT {PK} FROM {SolrQueryAggregatedStats}");
    org.fest.assertions.Assertions.assertThat(result.getResult()).hasSize(3);
  }
Example #7
0
  @Test
  public void testImplicitFlushWithDeletes() throws Exception {
    int numDelete = 3;

    Session session = openSession();
    session.beginTransaction();
    for (int i = 0; i < numDelete; i++) {
      session.persist(helicopter("H_" + i));
    }
    session.getTransaction().commit();
    session.close();

    LeakingMongoDBDialect.queueSize = -1;

    session = openSession();
    session.beginTransaction();
    List<Helicopter> helicopters = session.createQuery("FROM Helicopter").list();
    for (Helicopter helicopter : helicopters) {
      session.delete(helicopter);
    }
    session.getTransaction().commit();
    session.close();

    Assertions.assertThat(LeakingMongoDBDialect.queueSize).isEqualTo(numDelete);
  }
  @Test
  public void find() {

    HttpHeaders headers = new HttpHeaders();
    final HttpEntity<String> request = new HttpEntity<String>(headers);

    RestClient client = new RestClient();
    client.setApplicationPath("");
    String url = client.login("robin", "password");
    System.out.println(url);

    ResponseEntity<Currency[]> response =
        client
            .template()
            .exchange(client.apiUrl("currency"), HttpMethod.GET, request, Currency[].class);
    System.out.println("Response -->" + response.getBody());

    final Currency[] currency = response.getBody();
    if (currency != null) {
      System.out.println("Total currency Found " + currency.length);
    }
    for (int i = 0; i < currency.length; i++) {
      Assertions.assertThat(currency[i]).isNotNull();
    }
  }
  @Test
  public void actionOnlyBigAndPopupOnlyBigHaveSameHeight() {
    GuiActionRunner.execute(
        new GuiTask() {
          @Override
          protected void executeInEDT() throws Throwable {
            button1.setCommandButtonKind(CommandButtonKind.ACTION_ONLY);
            button2.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
            button1.setDisplayState(CommandButtonDisplayState.BIG);
            button2.setDisplayState(CommandButtonDisplayState.BIG);
          }
        });

    robot().waitForIdle();

    // button heights should be the same
    Assertions.assertThat(
            GuiActionRunner.execute(
                new GuiQuery<Boolean>() {
                  @Override
                  protected Boolean executeInEDT() throws Throwable {
                    return button1.getPreferredSize().height == button2.getPreferredSize().height;
                  }
                }))
        .isTrue();
  }
  @Test
  public void actionOnlySmallAndActionOnlyMediumHaveSameHeight() {
    GuiActionRunner.execute(
        new GuiTask() {
          @Override
          protected void executeInEDT() throws Throwable {
            button1.setCommandButtonKind(CommandButtonKind.ACTION_ONLY);
            button2.setCommandButtonKind(CommandButtonKind.ACTION_ONLY);
            button1.setDisplayState(CommandButtonDisplayState.SMALL);
            button2.setDisplayState(CommandButtonDisplayState.MEDIUM);
          }
        });

    robot().waitForIdle();

    // button heights should be the same
    Assertions.assertThat(
            GuiActionRunner.execute(
                new GuiQuery<Integer>() {
                  @Override
                  protected Integer executeInEDT() throws Throwable {
                    return button2.getPreferredSize().height - button1.getPreferredSize().height;
                  }
                }))
        .isZero();
  }
  @Test
  public void popupOnlySmallAndSplitSmallHaveDifferentWidth() {
    GuiActionRunner.execute(
        new GuiTask() {
          @Override
          protected void executeInEDT() throws Throwable {
            button1.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
            button2.setCommandButtonKind(CommandButtonKind.ACTION_AND_POPUP_MAIN_POPUP);
            button1.setDisplayState(CommandButtonDisplayState.SMALL);
            button2.setDisplayState(CommandButtonDisplayState.SMALL);
          }
        });

    robot().waitForIdle();

    // button widths should differ by the preferred width of a vertical
    // separator
    Assertions.assertThat(
            GuiActionRunner.execute(
                new GuiQuery<Integer>() {
                  @Override
                  protected Integer executeInEDT() throws Throwable {
                    return button2.getPreferredSize().width - button1.getPreferredSize().width;
                  }
                }))
        .isEqualTo(
            GuiActionRunner.execute(
                new GuiQuery<Integer>() {
                  @Override
                  protected Integer executeInEDT() throws Throwable {
                    return new JSeparator(JSeparator.VERTICAL).getPreferredSize().width;
                  }
                }));
  }
  @Test
  public void splitSmallAndSplitSmallHaveSameWidth() {
    GuiActionRunner.execute(
        new GuiTask() {
          @Override
          protected void executeInEDT() throws Throwable {
            button1.setCommandButtonKind(CommandButtonKind.ACTION_AND_POPUP_MAIN_ACTION);
            button2.setCommandButtonKind(CommandButtonKind.ACTION_AND_POPUP_MAIN_POPUP);
            button1.setDisplayState(CommandButtonDisplayState.SMALL);
            button2.setDisplayState(CommandButtonDisplayState.SMALL);
          }
        });

    robot().waitForIdle();

    // button heights should be the same
    Assertions.assertThat(
            GuiActionRunner.execute(
                new GuiQuery<Integer>() {
                  @Override
                  protected Integer executeInEDT() throws Throwable {
                    return button2.getPreferredSize().width - button1.getPreferredSize().width;
                  }
                }))
        .isZero();
  }
  @Test
  public void actionOnlyBigAndSplitBigHaveDifferentHeight() {
    GuiActionRunner.execute(
        new GuiTask() {
          @Override
          protected void executeInEDT() throws Throwable {
            button1.setCommandButtonKind(CommandButtonKind.ACTION_ONLY);
            button2.setCommandButtonKind(CommandButtonKind.ACTION_AND_POPUP_MAIN_POPUP);
            button1.setDisplayState(CommandButtonDisplayState.BIG);
            button2.setDisplayState(CommandButtonDisplayState.BIG);
          }
        });

    robot().waitForIdle();

    // button heights should differ by the preferred height of a horizontal
    // separator
    Assertions.assertThat(
            GuiActionRunner.execute(
                new GuiQuery<Integer>() {
                  @Override
                  protected Integer executeInEDT() throws Throwable {
                    return button2.getPreferredSize().height - button1.getPreferredSize().height;
                  }
                }))
        .isEqualTo(
            GuiActionRunner.execute(
                new GuiQuery<Integer>() {
                  @Override
                  protected Integer executeInEDT() throws Throwable {
                    return new JSeparator(JSeparator.HORIZONTAL).getPreferredSize().height;
                  }
                }));
  }
  @Test
  public void testPayment() {
    EmvTransactionRecord payment = new EmvTransactionRecord();
    payment.setAmount((float) 100.0);
    payment.setCurrency(CurrencyEnum.EUR);
    payment.setCyptogramData("12");
    payment.setTerminalCountry(CountryCodeEnum.FR);
    payment.setTransactionDate(new Date());
    payment.setTransactionType(TransactionTypeEnum.CASHBACK);

    Assertions.assertThat(payment.getAmount()).isEqualTo(100);
    Assertions.assertThat(payment.getCurrency()).isEqualTo(CurrencyEnum.EUR);
    Assertions.assertThat(payment.getCyptogramData()).isEqualTo("12");
    Assertions.assertThat(payment.getTerminalCountry()).isEqualTo(CountryCodeEnum.FR);
    Assertions.assertThat(payment.getTransactionType()).isEqualTo(TransactionTypeEnum.CASHBACK);
  }
  /**
   * Performs a very simple stress test using a pooling {@link Controller}. The test is performed
   * with default init attributes.
   */
  @Nightly
  @Test
  @ThreadLeakLingering(linger = 5000)
  public void testStress() throws InterruptedException, ExecutionException {
    final int numberOfThreads = randomIntBetween(1, 10);
    final int queriesPerThread = scaledRandomIntBetween(5, 25);

    /*
     * This yields a pooling controller effectively, because no cache interfaces are passed.
     */
    @SuppressWarnings("unchecked")
    final Controller controller = getCachingController(initAttributes);

    ExecutorService executorService = Executors.newFixedThreadPool(numberOfThreads);
    List<Callable<ProcessingResult>> callables = Lists.newArrayList();
    for (int i = 0; i < numberOfThreads * queriesPerThread; i++) {
      final int dataSetIndex = i;
      callables.add(
          new Callable<ProcessingResult>() {
            public ProcessingResult call() throws Exception {
              Map<String, Object> localAttributes = Maps.newHashMap();
              localAttributes.put(
                  AttributeNames.DOCUMENTS,
                  SampleDocumentData.ALL.get(dataSetIndex % SampleDocumentData.ALL.size()));
              localAttributes.put("dataSetIndex", dataSetIndex);
              return controller.process(localAttributes, getComponentClass());
            }
          });
    }

    try {
      List<Future<ProcessingResult>> results = executorService.invokeAll(callables);
      Multimap<Integer, List<Cluster>> clusterings = ArrayListMultimap.create();

      // Group results by query
      for (Future<ProcessingResult> future : results) {
        final ProcessingResult processingResult = future.get();
        final Integer dataSetIndex = (Integer) processingResult.getAttributes().get("dataSetIndex");
        clusterings.put(dataSetIndex, processingResult.getClusters());
      }

      // Make sure results are the same within each data set
      for (Integer dataSetIndex : clusterings.keySet()) {
        Collection<List<Cluster>> clustering = clusterings.get(dataSetIndex);
        Iterator<List<Cluster>> iterator = clustering.iterator();
        if (!iterator.hasNext()) {
          continue;
        }

        final List<Cluster> firstClusterList = iterator.next();
        Assertions.assertThat(firstClusterList).isNotEmpty();
        while (iterator.hasNext()) {
          assertThatClusters(firstClusterList).isEquivalentTo(iterator.next());
        }
      }
    } finally {
      executorService.shutdown();
    }
  }
  @Test
  public void testDisableCollectingStatistics() {
    // given
    solrQueryStatisticsCollectorJob.setEnableCollectingStatistics(false);

    // when
    final PerformResult perform = solrQueryStatisticsCollectorJob.perform(null);

    // then
    org.fest.assertions.Assertions.assertThat(perform.getResult()).isEqualTo(CronJobResult.SUCCESS);
    org.fest.assertions.Assertions.assertThat(perform.getStatus())
        .isEqualTo(CronJobStatus.FINISHED);

    final SearchResult<SolrQueryAggregatedStatsModel> result =
        flexibleSearchService.search("SELECT {PK} FROM {SolrQueryAggregatedStats}");
    org.fest.assertions.Assertions.assertThat(result.getResult()).isEmpty();
  }
  @Test
  public void festCollectionSupport() {
    List<String> l1 = new ArrayList<String>();
    l1.add("a1");
    l1.add("a2");

    Assertions.assertThat(l1).isNotNull().containsExactly("a1", "a2");
  }
  @Test
  public void testMergingIntoMostSpecificWithMoreLanguages() {
    final DefaultChangeSetBuilder builder = new DefaultChangeSetBuilder();

    builder.setLocalizedAttributesProcessor(processor);

    final Map<Locale, Set<String>> dirtyLocalizedAttributes = new LinkedHashMap<>();

    fillAttributes(dirtyLocalizedAttributes, ROOT_LOCALE_DE, "foo", "bar", "baz");
    fillAttributes(dirtyLocalizedAttributes, LEAF_LOCALE_EN, "roo", "rar", "raz");
    fillAttributes(dirtyLocalizedAttributes, MID_LOCALE_DE, "mi-foo", "bar", "mi-baz");
    fillAttributes(
        dirtyLocalizedAttributes, OTHER_LEAF_LOCALE_EN, "other-foo", "other-bar", "baz", "razr");
    fillAttributes(dirtyLocalizedAttributes, LEAF_LOCALE_DE, "li-foo", "bar", "mi-baz", "baz");
    fillAttributes(dirtyLocalizedAttributes, MID_LOCALE_EN, "mi-roo", "rar");
    fillAttributes(dirtyLocalizedAttributes, ROOT_LOCALE_EN, "roo", "rar", "raz", "razr");

    final Map<Locale, Set<String>> resultLocalizedAttributes =
        builder.preProcessLocalizedAttributes(dirtyLocalizedAttributes);

    Assertions.assertThat(resultLocalizedAttributes.get(ROOT_LOCALE_DE)).containsOnly("foo");
    Assertions.assertThat(resultLocalizedAttributes.get(MID_LOCALE_DE)).containsOnly("mi-foo");
    Assertions.assertThat(resultLocalizedAttributes.get(LEAF_LOCALE_DE))
        .containsOnly("li-foo", "bar", "mi-baz", "baz");

    Assertions.assertThat(resultLocalizedAttributes.get(ROOT_LOCALE_EN)).isNullOrEmpty();
    Assertions.assertThat(resultLocalizedAttributes.get(MID_LOCALE_EN)).containsOnly("mi-roo");
    Assertions.assertThat(resultLocalizedAttributes.get(LEAF_LOCALE_EN))
        .containsOnly("roo", "rar", "raz");
    Assertions.assertThat(resultLocalizedAttributes.get(OTHER_LEAF_LOCALE_EN))
        .containsOnly("other-foo", "other-bar", "baz", "razr");
  }
 @Test
 public void shouldGetCarAnalysisByTimestamp() {
   // given
   AnalysisComponentFactory factory = new CarAnalysisComponentFactory();
   // when
   Analysis analysis = AnalysisContainer.getAnalysisBy(AnalysisBy.TIMESTAMP, factory);
   // then
   Assertions.assertThat(analysis).isInstanceOf(CarAnalysisByTimestamp.class);
 }
Example #20
0
 @Test
 public void shouldReportErrorWhenAddingANullInvocationListener() throws Exception {
   try {
     mockSettingsImpl.invocationListeners(invocationListener, null);
     fail();
   } catch (Exception e) {
     Assertions.assertThat(e.getMessage()).contains("does not accept null");
   }
 }
Example #21
0
 @Test
 public void shouldReportErrorWhenAddingNoInvocationListeners() throws Exception {
   try {
     mockSettingsImpl.invocationListeners();
     fail();
   } catch (Exception e) {
     Assertions.assertThat(e.getMessage()).contains("at least one listener");
   }
 }
  @Test
  public void testParseInlineContentDispostionHeaderMimePart() {
    MimeMessage message = GreenMailUtil.newMimeMessage(sampleEmail);

    SimpleMessageAttributes simpleMessageAttributes = new SimpleMessageAttributes();
    simpleMessageAttributes.parseMimePart(message);

    String bodyStructure = simpleMessageAttributes.getBodyStructure(true);
    Assertions.assertThat(bodyStructure).contains("(\"inline\" NIL)");
  }
  public TableAssert hasRow(String... keyValuePairs) {

    @SuppressWarnings("unchecked")
    final Row expectedRow = new Row((Map<String, String>) new Yaml().load(flatten(keyValuePairs)));

    List<Row> rows = extractRows();
    Assertions.assertThat(rows).contains(expectedRow);

    return this;
  }
  public GearGroupAssert hasCartridges(final String... expectedCartridgeNames) {
    final Collection<ICartridge> existingCartridges = gearGroup.getCartridges();
    final List<String> existingCartridgeNames = new ArrayList<String>();
    final Iterator<ICartridge> cartridgeIterator = existingCartridges.iterator();
    for (int i = 0; i < existingCartridges.size(); i++) {
      existingCartridgeNames.add(cartridgeIterator.next().getName());
    }

    Assertions.assertThat(existingCartridgeNames).isEqualTo(Arrays.asList(expectedCartridgeNames));
    return this;
  }
  @Test
  public void startSession_should_be_indicated_in_recording_state() throws Exception {
    // given

    // when
    sessionManager.startMobileSession(false);

    // then
    org.fest.assertions.Assertions.assertThat(sessionManager.state.recording().isRecording())
        .isTrue();
  }
  @Test
  public void shouldStoreMeasurements() {
    sessionManager.startMobileSession(false);

    triggerMeasurement(22);

    Measurement expected = new Measurement(location.getLatitude(), location.getLongitude(), 22);
    org.fest.assertions.Assertions.assertThat(
            sessionManager.getMeasurementStream("LHC").getMeasurements())
        .contains(expected);
  }
Example #27
0
  @Test
  public void shouldAddVerboseLoggingListenerOnlyOnce() {
    // given
    assertFalse(mockSettingsImpl.hasInvocationListeners());

    // when
    mockSettingsImpl.verboseLogging().verboseLogging();

    // then
    Assertions.assertThat(mockSettingsImpl.getInvocationListeners()).hasSize(1);
  }
Example #28
0
  @Test
  public void shouldAddInvocationListener() {
    // given
    assertFalse(mockSettingsImpl.hasInvocationListeners());

    // when
    mockSettingsImpl.invocationListeners(invocationListener);

    // then
    Assertions.assertThat(mockSettingsImpl.getInvocationListeners()).contains(invocationListener);
  }
Example #29
0
 @Test
 public void instrumentSynchronizedTest() throws Exception {
   Launcher l = new Launcher();
   l.addInputResource("src/test/java");
   l.buildModel();
   CtClass<?> sample =
       ((CtClass<?>)
           (l.getFactory()
               .Package()
               .getRootPackage()
               .getElements(
                   new spoon.reflect.visitor.filter.NameFilter<
                       spoon.reflect.declaration.CtNamedElement>("SynchronizedSample"))
               .get(0)));
   Integer nbSynchronizedBlock = 2;
   Integer nbStatementToInsert = 2;
   Insertion insertionStrategy = new SynchronizedInsert();
   CtStatement statementToInsert =
       l.getFactory().Code().createCodeSnippetStatement("TO BE INSERT");
   Assertions.assertThat(
           sample
               .getElements(
                   new spoon.reflect.visitor.filter.TypeFilter<
                       spoon.reflect.declaration.CtElement>(CtElement.class))
               .stream()
               .filter(insertionStrategy::match)
               .collect(java.util.stream.Collectors.toList()))
       .hasSize(nbSynchronizedBlock);
   sample
       .getElements(
           new spoon.reflect.visitor.filter.TypeFilter<spoon.reflect.declaration.CtElement>(
               CtElement.class))
       .stream()
       .filter(insertionStrategy::match)
       .forEach((CtElement element) -> insertionStrategy.apply(element, statementToInsert));
   System.out.println(sample);
   Assertions.assertThat(
           sample.getElements(
               new fil.iagl.opl.rendu.two.tools.ContainsSameElementFilter(statementToInsert)))
       .hasSize(nbStatementToInsert);
 }
  @Test
  public void stopSession_should_changeRecordingState() throws Exception {
    // given
    sessionManager.startMobileSession(false);

    // when
    sessionManager.stopSession();

    // then
    org.fest.assertions.Assertions.assertThat(sessionManager.state.recording().isRecording())
        .isFalse();
  }