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");
}
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);
}
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;
}
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);
}
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");
}
Aggregations