Search in sources :

Example 6 with I18n

use of org.xnap.commons.i18n.I18n in project candlepin by candlepin.

the class ProductResourceTest method testDeleteProductWithSubscriptions.

@Test(expected = BadRequestException.class)
public void testDeleteProductWithSubscriptions() {
    ProductCurator pc = mock(ProductCurator.class);
    I18n i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    ProductResource pr = new ProductResource(pc, null, null, config, i18n, this.modelTranslator);
    Owner o = mock(Owner.class);
    Product p = mock(Product.class);
    // when(pc.lookupById(eq(o), eq("10"))).thenReturn(p);
    Set<Subscription> subs = new HashSet<>();
    Subscription s = mock(Subscription.class);
    subs.add(s);
    when(pc.productHasSubscriptions(eq(o), eq(p))).thenReturn(true);
    pr.deleteProduct("10");
}
Also used : Owner(org.candlepin.model.Owner) ProductCurator(org.candlepin.model.ProductCurator) Product(org.candlepin.model.Product) Subscription(org.candlepin.model.dto.Subscription) I18n(org.xnap.commons.i18n.I18n) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with I18n

use of org.xnap.commons.i18n.I18n in project candlepin by candlepin.

the class BasicAuthViaUserServiceTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    headerMap = new MultivaluedMapImpl<>();
    when(mockHeaders.getRequestHeaders()).thenReturn(headerMap);
    when(request.getHttpHeaders()).thenReturn(mockHeaders);
    when(mockHeaders.getRequestHeader(anyString())).then(new Answer<List<String>>() {

        public List<String> answer(InvocationOnMock invocation) {
            Object[] args = invocation.getArguments();
            return headerMap.get(args[0]);
        }
    });
    I18n i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    when(mockI18n.get()).thenReturn(i18n);
    this.auth = new BasicAuth(userService, mockI18n);
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) ArrayList(java.util.ArrayList) List(java.util.List) I18n(org.xnap.commons.i18n.I18n) Before(org.junit.Before)

Example 8 with I18n

use of org.xnap.commons.i18n.I18n in project candlepin by candlepin.

the class ModeManagerTest method setUp.

@Before
public void setUp() {
    I18n mockedi18 = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    modeManager = new ModeManagerImpl(new CandlepinCommonTestConfig(), mockedi18);
    testReason = Reason.STARTUP;
    modeChanged = false;
}
Also used : CandlepinCommonTestConfig(org.candlepin.config.CandlepinCommonTestConfig) I18n(org.xnap.commons.i18n.I18n) Before(org.junit.Before)

Example 9 with I18n

use of org.xnap.commons.i18n.I18n in project candlepin by candlepin.

the class TrustedUserAuthTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    headerMap = new MultivaluedMapImpl<>();
    when(mockHeaders.getRequestHeaders()).thenReturn(headerMap);
    when(mockHeaders.getRequestHeader(anyString())).then(new Answer<List<String>>() {

        public List<String> answer(InvocationOnMock invocation) {
            Object[] args = invocation.getArguments();
            return headerMap.get(args[0]);
        }
    });
    when(request.getHttpHeaders()).thenReturn(mockHeaders);
    I18n i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    when(mockI18n.get()).thenReturn(i18n);
    this.auth = new TrustedUserAuth(userService, mockI18n);
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) List(java.util.List) I18n(org.xnap.commons.i18n.I18n) Before(org.junit.Before)

Example 10 with I18n

use of org.xnap.commons.i18n.I18n in project candlepin by candlepin.

the class OwnerProductResourceTest method testDeleteProductWithSubscriptions.

@Test(expected = BadRequestException.class)
public void testDeleteProductWithSubscriptions() {
    OwnerCurator oc = mock(OwnerCurator.class);
    OwnerProductCurator opc = mock(OwnerProductCurator.class);
    ProductCurator pc = mock(ProductCurator.class);
    I18n i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    OwnerProductResource pr = new OwnerProductResource(config, i18n, oc, null, opc, null, pc, null, this.modelTranslator);
    Owner o = mock(Owner.class);
    Product p = mock(Product.class);
    when(oc.lookupByKey(eq("owner"))).thenReturn(o);
    when(opc.getProductById(eq(o), eq("10"))).thenReturn(p);
    Set<Subscription> subs = new HashSet<>();
    Subscription s = mock(Subscription.class);
    subs.add(s);
    when(pc.productHasSubscriptions(eq(o), eq(p))).thenReturn(true);
    pr.deleteProduct("owner", "10");
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) OwnerProductCurator(org.candlepin.model.OwnerProductCurator) ProductCurator(org.candlepin.model.ProductCurator) Product(org.candlepin.model.Product) Subscription(org.candlepin.model.dto.Subscription) OwnerProductCurator(org.candlepin.model.OwnerProductCurator) I18n(org.xnap.commons.i18n.I18n) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

I18n (org.xnap.commons.i18n.I18n)11 Before (org.junit.Before)6 Owner (org.candlepin.model.Owner)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Locale (java.util.Locale)2 BadRequestException (org.candlepin.common.exceptions.BadRequestException)2 Product (org.candlepin.model.Product)2 ProductCurator (org.candlepin.model.ProductCurator)2 Subscription (org.candlepin.model.dto.Subscription)2 Test (org.junit.Test)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 OAuthAccessor (net.oauth.OAuthAccessor)1 OAuthException (net.oauth.OAuthException)1 OAuthMessage (net.oauth.OAuthMessage)1 OAuthProblemException (net.oauth.OAuthProblemException)1 EventAdapterImpl (org.candlepin.audit.EventAdapterImpl)1