Search in sources :

Example 1 with SourceResult

use of com.searchcode.app.model.SourceResult in project searchcode-server by boyter.

the class SourceTest method testGetSourceByIdCache.

public void testGetSourceByIdCache() {
    if (Singleton.getHelpers().isStandaloneInstance())
        return;
    var cache = CacheSingleton.getSourceCache();
    cache.put("d.s.999", Optional.of(new SourceResult().setId(999).setName("ZeName")));
    var newSource = new Source(Singleton.getDatabaseConfig(), new Helpers(), Singleton.getLogger(), cache);
    var result = newSource.getSourceById(999);
    assertThat(result.get().id).isEqualTo(999);
    assertThat(result.get().name).isEqualTo("ZeName");
}
Also used : SourceResult(com.searchcode.app.model.SourceResult) Helpers(com.searchcode.app.util.Helpers)

Example 2 with SourceResult

use of com.searchcode.app.model.SourceResult in project searchcode-server by boyter.

the class SourceTest method testGetSourceByNameCache.

public void testGetSourceByNameCache() {
    if (Singleton.getHelpers().isStandaloneInstance())
        return;
    var cache = CacheSingleton.getSourceCache();
    cache.put("d.s.ZeName", Optional.of(new SourceResult().setId(999).setName("ZeName")));
    var newSource = new Source(Singleton.getDatabaseConfig(), new Helpers(), Singleton.getLogger(), cache);
    var result = newSource.getSourceByName("ZeName");
    assertThat(result.get().id).isEqualTo(999);
    assertThat(result.get().name).isEqualTo("ZeName");
}
Also used : SourceResult(com.searchcode.app.model.SourceResult) Helpers(com.searchcode.app.util.Helpers)

Aggregations

SourceResult (com.searchcode.app.model.SourceResult)2 Helpers (com.searchcode.app.util.Helpers)2