Search in sources :

Example 11 with BaseConfig

use of org.nzbhydra.config.BaseConfig in project nzbhydra2 by theotherp.

the class LogAnonymizerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    BaseConfig baseConfig = new BaseConfig();
    when(configProviderMock.getBaseConfig()).thenReturn(baseConfig);
    UserAuthConfig user = new UserAuthConfig();
    user.setUsername("someusername");
    baseConfig.getAuth().getUsers().add(user);
}
Also used : UserAuthConfig(org.nzbhydra.config.UserAuthConfig) BaseConfig(org.nzbhydra.config.BaseConfig) Before(org.junit.Before)

Example 12 with BaseConfig

use of org.nzbhydra.config.BaseConfig in project nzbhydra2 by theotherp.

the class IndexerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    when(indexerMock.getIndexerEntity()).thenReturn(indexerEntityMock);
    when(indexerMock.getConfig()).thenReturn(indexerConfig);
    when(indexerEntityMock.getName()).thenReturn("indexerName");
    when(indexerMock.getName()).thenReturn("indexerName");
    testee.indexer = indexerEntityMock;
    testee.config = indexerConfig;
    indexerConfig.setTimeout(1);
    baseConfig = new BaseConfig();
    when(configProviderMock.getBaseConfig()).thenReturn(baseConfig);
    baseConfig.getSearching().setIdFallbackToQueryGeneration(SearchSourceRestriction.BOTH);
    when(resultAcceptor.acceptResults(anyList(), any(), any())).then(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return new AcceptorResult(invocation.getArgument(0), HashMultiset.create());
        }
    });
    when(infoProviderMock.convert(anyString(), any())).thenReturn(new MediaInfo(new TvInfo("tvdbid", "tvrageid", "tvmazeid", "title", 2017, "")));
    testee = spy(testee);
}
Also used : AcceptorResult(org.nzbhydra.searching.SearchResultAcceptor.AcceptorResult) MediaInfo(org.nzbhydra.mediainfo.MediaInfo) InvocationOnMock(org.mockito.invocation.InvocationOnMock) TvInfo(org.nzbhydra.mediainfo.TvInfo) BaseConfig(org.nzbhydra.config.BaseConfig) Before(org.junit.Before)

Example 13 with BaseConfig

use of org.nzbhydra.config.BaseConfig in project nzbhydra2 by theotherp.

the class IndexerWebAccessTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    String xml = "<?xml version=\"1.0\" ?>\n" + "<metadata>\n" + "</metadata>";
    when(webAccessMock.callUrl(anyString(), headersCaptor.capture(), timeoutCaptor.capture())).thenReturn(xml);
    BaseConfig baseConfig = new BaseConfig();
    baseConfig.setSearching(searchingConfigMock);
    when(configProviderMock.getBaseConfig()).thenReturn(baseConfig);
    when(searchingConfigMock.getUserAgent()).thenReturn(Optional.of("globalUa"));
    when(searchingConfigMock.getTimeout()).thenReturn(100);
    indexerConfig.setTimeout(10);
    indexerConfig.setUserAgent("indexerUa");
    when(unmarshallerMock.unmarshal(any())).thenReturn(new NewznabXmlRoot());
}
Also used : NewznabXmlRoot(org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BaseConfig(org.nzbhydra.config.BaseConfig) Before(org.junit.Before)

Aggregations

BaseConfig (org.nzbhydra.config.BaseConfig)13 Before (org.junit.Before)7 Test (org.junit.Test)3 ConfigChangedEvent (org.nzbhydra.config.ConfigChangedEvent)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 SearchingConfig (org.nzbhydra.config.SearchingConfig)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)1 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)1 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Ignore (org.junit.Ignore)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 CategoriesConfig (org.nzbhydra.config.CategoriesConfig)1 Category (org.nzbhydra.config.Category)1 IndexerCategoryConfig (org.nzbhydra.config.IndexerCategoryConfig)1 IndexerConfig (org.nzbhydra.config.IndexerConfig)1 UserAuthConfig (org.nzbhydra.config.UserAuthConfig)1 NewznabXmlRoot (org.nzbhydra.mapping.newznab.xml.NewznabXmlRoot)1