Search in sources :

Example 1 with Language

use of com.redhat.devtools.alizer.api.Language in project intellij-tekton by redhat-developer.

the class HubItemScoreTest method Compare_2HubItems_VerifyCalculatedScoreWithDescription.

@Test
public void Compare_2HubItems_VerifyCalculatedScoreWithDescription() {
    Language lang = new Language("First", Arrays.asList("alias1", "alias2"), 99.0, Arrays.asList("framework1"), Collections.emptyList(), false);
    Language lang2 = new Language("Second", Arrays.asList("alias3", "alias4"), 1.0, Arrays.asList("framework2"), Collections.emptyList(), false);
    List<Language> languages = Arrays.asList(lang, lang2);
    Tag tag2 = buildTag("framework2");
    Tag tag3 = buildTag("framework3");
    HubItem hubItem1 = buildHubItem("name", "this is the first item for the first language", Collections.emptyList());
    HubItem hubItem2 = buildHubItem("name2", "blabla", Arrays.asList(tag2, tag3));
    HubItemScore hubItemScore = new HubItemScore(languages);
    assertEquals(2, hubItemScore.compare(hubItem1, hubItem2));
}
Also used : Language(com.redhat.devtools.alizer.api.Language) Tag(com.redhat.devtools.intellij.tektoncd.hub.model.Tag) Test(org.junit.Test)

Example 2 with Language

use of com.redhat.devtools.alizer.api.Language in project intellij-tekton by redhat-developer.

the class HubItemScoreTest method Compare_1HubItemAndValue_VerifyCalculatedScoreWithOnlyName.

@Test
public void Compare_1HubItemAndValue_VerifyCalculatedScoreWithOnlyName() {
    Language lang = new Language("First", Collections.emptyList(), 99.0, false);
    Language lang2 = new Language("Second", Collections.emptyList(), 1.0, false);
    List<Language> languages = Arrays.asList(lang, lang2);
    HubItem hubItem1 = buildHubItem("Second", "", Collections.emptyList());
    HubItemScore hubItemScore = new HubItemScore(languages);
    assertEquals(19, hubItemScore.compare(hubItem1, 1));
}
Also used : Language(com.redhat.devtools.alizer.api.Language) Test(org.junit.Test)

Example 3 with Language

use of com.redhat.devtools.alizer.api.Language in project intellij-tekton by redhat-developer.

the class HubItemScoreTest method Compare_2HubItems_VerifyCalculatedScoreWithAliases.

@Test
public void Compare_2HubItems_VerifyCalculatedScoreWithAliases() {
    Language lang = new Language("First", Arrays.asList("alias1", "alias2"), 99.0, false);
    Language lang2 = new Language("Second", Arrays.asList("alias3", "alias4"), 1.0, false);
    List<Language> languages = Arrays.asList(lang, lang2);
    HubItem hubItem1 = buildHubItem("alias1", "", Collections.emptyList());
    HubItem hubItem2 = buildHubItem("alias4", "", Collections.emptyList());
    HubItemScore hubItemScore = new HubItemScore(languages);
    assertEquals(20, hubItemScore.compare(hubItem1, hubItem2));
}
Also used : Language(com.redhat.devtools.alizer.api.Language) Test(org.junit.Test)

Example 4 with Language

use of com.redhat.devtools.alizer.api.Language in project intellij-tekton by redhat-developer.

the class HubItemScoreTest method Compare_1HubItemAndValue_VerifyCalculatedScoreWithFrameworks.

@Test
public void Compare_1HubItemAndValue_VerifyCalculatedScoreWithFrameworks() {
    Language lang = new Language("First", Arrays.asList("alias1", "alias2"), 99.0, Arrays.asList("framework1"), Collections.emptyList(), false);
    Language lang2 = new Language("Second", Arrays.asList("alias3", "alias4"), 1.0, Arrays.asList("framework2"), Collections.emptyList(), false);
    List<Language> languages = Arrays.asList(lang, lang2);
    Tag tag = buildTag("framework1");
    HubItem hubItem1 = buildHubItem("name", "", Arrays.asList(tag));
    HubItemScore hubItemScore = new HubItemScore(languages);
    assertEquals(19, hubItemScore.compare(hubItem1, 1));
}
Also used : Language(com.redhat.devtools.alizer.api.Language) Tag(com.redhat.devtools.intellij.tektoncd.hub.model.Tag) Test(org.junit.Test)

Example 5 with Language

use of com.redhat.devtools.alizer.api.Language in project intellij-tekton by redhat-developer.

the class HubItemScoreTest method Compare_2HubItems_VerifyCalculatedScoreWithFrameworks.

@Test
public void Compare_2HubItems_VerifyCalculatedScoreWithFrameworks() {
    Language lang = new Language("First", Arrays.asList("alias1", "alias2"), 99.0, Arrays.asList("framework1"), Collections.emptyList(), false);
    Language lang2 = new Language("Second", Arrays.asList("alias3", "alias4"), 1.0, Arrays.asList("framework2"), Collections.emptyList(), false);
    List<Language> languages = Arrays.asList(lang, lang2);
    Tag tag = buildTag("framework1");
    Tag tag2 = buildTag("framework2");
    Tag tag3 = buildTag("framework3");
    HubItem hubItem1 = buildHubItem("name", "", Arrays.asList(tag));
    HubItem hubItem2 = buildHubItem("name2", "", Arrays.asList(tag2, tag3));
    HubItemScore hubItemScore = new HubItemScore(languages);
    assertEquals(10, hubItemScore.compare(hubItem1, hubItem2));
}
Also used : Language(com.redhat.devtools.alizer.api.Language) Tag(com.redhat.devtools.intellij.tektoncd.hub.model.Tag) Test(org.junit.Test)

Aggregations

Language (com.redhat.devtools.alizer.api.Language)13 Test (org.junit.Test)11 RecognizerFactory (com.redhat.devtools.alizer.api.RecognizerFactory)3 Tag (com.redhat.devtools.intellij.tektoncd.hub.model.Tag)3 LanguageRecognizer (com.redhat.devtools.alizer.api.LanguageRecognizer)2 ResourceApi (com.redhat.devtools.intellij.tektoncd.hub.api.ResourceApi)2 ResourceData (com.redhat.devtools.intellij.tektoncd.hub.model.ResourceData)2 ResourceVersionData (com.redhat.devtools.intellij.tektoncd.hub.model.ResourceVersionData)2 Resources (com.redhat.devtools.intellij.tektoncd.hub.model.Resources)2 Strings (com.google.common.base.Strings)1 BaseTest (com.redhat.devtools.intellij.tektoncd.BaseTest)1 ClusterTasksNode (com.redhat.devtools.intellij.tektoncd.tree.ClusterTasksNode)1 PipelinesNode (com.redhat.devtools.intellij.tektoncd.tree.PipelinesNode)1 Watch (io.fabric8.kubernetes.client.Watch)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Before (org.junit.Before)1