src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
OctetStringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OCTET_STRING; assert !context.getTag().isConstructed(); if( context.getLength() == -1 ) return readByteArrayValueIndefinite( co...
@Test( expected = AssertionError.class ) public void testDecode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); try( AbstractBerReader reader = mock( DefaultBerReader.class ) ) { Tag tag = ( (TagEncoding)type.getEncoding( Enc...
RealBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert context.getValue().getKind() == Kind.REAL || context.getValue().getKind() == Kind.INTEGER; if( context.getValue().getKind() == Kind.REAL ...
@Test( expected = AssertionError.class ) public void testWrite_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = new IntegerValueInt( 0 ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new Re...
RealBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.REAL; assert !context.getTag().isConstructed(); if( context.getLength() == 0 ) return context.getValueFactory().rZero(); byte first = context.read();...
@Test( expected = AssertionError.class ) public void testDecode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); try( AbstractBerReader reader = mock( DefaultBerReader.class ) ) { Tag tag = ( (TagEncoding)type.getEncoding( Enc...
IntegerBerEncoder implements BerEncoder { static void writeLong( @NotNull AbstractBerWriter os, long value, @Nullable Tag tag, boolean writeHeader ) throws IOException { if( tag == null && writeHeader ) throw new IOException( "Unable to write header: tag is unavailable." ); int size = calculateByteCount( value ); if( w...
@Test public void testWriteLong_0() throws Exception { try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { IntegerBerEncoder.writeLong( writer, 0L, null, false ); verify( writer ).write( 0 ); verifyNoMoreInteractions( writer ); } } @Test public void testWriteLong_minus_1() throws Exception { try( Abstra...
IntegerBerEncoder implements BerEncoder { static byte[] toByteArray( long value ) { int size = calculateByteCount( value ); byte[] result = new byte[size]; for( int i = size - 1, position = 0; i >= 0; i--, position++ ) result[position] = getByteByIndex( value, i ); return result; } @Override void encode( @NotNull Writ...
@Test public void testToByteArray_0() throws Exception { byte[] array = IntegerBerEncoder.toByteArray( 0L ); Assert.assertEquals( "Illegal array size", 1, array.length ); Assert.assertArrayEquals( "Arrays are different", new byte[]{0}, array ); } @Test public void testToByteArray_minus_1() throws Exception { byte[] arr...
IntegerBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getLength() >= 0; return readInteger( context.getReader(), context.getLength() ); } @Override Value decode( @NotNull Read...
@Test( expected = AssertionError.class ) public void testDecode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.REAL.ref().resolve( scope ); try( AbstractBerReader reader = mock( DefaultBerReader.class ) ) { Tag tag = ( (TagEncoding)type.getEncoding( Encodi...
IntegerBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.INTEGER; assert context.getValue().getKind() == Kind.INTEGER; writeLong( context.getWriter(), context.getValue().toIntegerValue().asLong(), TAG, co...
@Test public void testEncode_0() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); Value value = new IntegerValueInt( 0 ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new IntegerBerEncoder().encode( new WriterContex...
ObjectIDBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.OID; assert context.getValue().getKind() == Kind.OID; if( !context.isWriteHeader() ) writeObjectIDImpl( context.getWriter(), contex...
@Test public void testEncode_NoHeader() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.OBJECT_IDENTIFIER.ref().resolve( scope ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new ObjectIDBerEncoder().encode( new WriterContext( writer, scope, type...
StringBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.RESTRICTED_STRING; Type type = context.getType(); while( !( type instanceof StringType ) ) { assert type != null; type = type.getSib...
@Test public void testDecode() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.UTF8_STRING.ref().resolve( scope ); Value value = new StringValueImpl( "Example" ); byte[] result = InputUtils.writeValue( scope, type, value ); int totalWritten = result.length - 2; byte[] ...
NullBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.NULL; assert context.getValue().getKind() == Kind.NULL; context.writeHeader( TAG, 0 ); } @Override void encode( @NotNull WriterContext context ); }
@Test public void testEncode_value_no_header() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.NULL.ref().resolve( scope ); Value value = NullValue.INSTANCE; try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { new NullBerEncoder().encode( new WriterCont...
UTCTimeBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.UTC_TIME; assert context.getValue().getKind() == Kind.TIME; String content = TimeUtils.formatInstant( context.getValue().toDateValue...
@Test public void testWrite_Der() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.UTC_TIME.ref().resolve( scope ); Value value = new DateValueImpl( TimeUtils.parseUTCTime( TIME_VALUE ) ); try( AbstractBerWriter writer = mock( AbstractBerWriter.class ) ) { when( writer....
EnumeratedBerEncoder implements BerEncoder { @Override public void encode( @NotNull WriterContext context ) throws IOException { assert context.getType().getFamily() == Family.ENUMERATED; assert context.getValue().getKind() == Kind.NAME && context.getValue().toNamedValue().getReferenceKind() == Kind.INTEGER; IntegerBer...
@Test public void testEncode_0() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Enumerated type = new EnumeratedType(); type.addItem( ItemKind.PRIMARY, "a", new IntegerValueInt( 0 ) ); type.validate( scope ); Value value = type.optimize( scope, new IntegerValueInt( 0 ) ); try( AbstractBerWrite...
GroupSyntaxObject implements SyntaxObject { @Override public String getText() { throw new UnsupportedOperationException(); } @Override Kind getKind(); @Override String getText(); void addObject( SyntaxObject object ); List<SyntaxObject> getObjects(); }
@Test( expected = UnsupportedOperationException.class ) public void testGetTextFail() { new GroupSyntaxObject().getText(); Assert.fail( "Exception was not thrown" ); }
GroupSyntaxObject implements SyntaxObject { public void addObject( SyntaxObject object ) { objects.add( object ); } @Override Kind getKind(); @Override String getText(); void addObject( SyntaxObject object ); List<SyntaxObject> getObjects(); }
@Test public void testAddObject() { GroupSyntaxObject group = new GroupSyntaxObject(); Assert.assertEquals( "Kind is not GROUP", Kind.GROUP, group.getKind() ); Assert.assertTrue( "Collection is not empty", group.getObjects().isEmpty() ); group.addObject( new SimpleSyntaxObject( Kind.KEYWORD, "VALUE" ) ); Assert.assertE...
FileQueueService { public QueueFile getQueueFile() { return this.queueFile; } @Autowired FileQueueService(@Value("${modum.tokenapp.email.queue-file-path}") String queueFilePath, @Autowired ObjectMapper objectMapper); FileQueueService(String queueFilePath); FileQueueService(); QueueFile ge...
@Test public void testFileQueue() throws IOException { FileQueueService fileQueueService = new FileQueueService(getTempFilePath()); fileQueueService.getQueueFile().add("test".getBytes()); assertThat(fileQueueService.getQueueFile().peek(), is("test".getBytes())); } @Test public void testFileQueueRecovering() throws IOEx...
Minting { public void mint(List<Token> tokens) throws ExecutionException, InterruptedException { for(Token token:tokens) { if(modumToken == null) { LOG.error("no modum token bean created"); } else { Future<TransactionReceipt> receipt = modumToken.mint(new Address(token.getWalletAddress()), new Uint256(token.getAmount()...
@Test public void testMintingLarge() throws ExecutionException, InterruptedException { dataBtc(1).dataBtc(2); rateBtc(101, 1_050_000); rateBtc(102, 7); int current = 0; current = minting.mint(current, 100, 0, 1 * 100_000_000, 0, "w1"); Assert.assertEquals(2_100_000, current); current = minting.mint(current, 102, 0, 1 *...
SendEmailTask { public SendEmailTask() { } SendEmailTask(); @Scheduled(initialDelay = 10000, fixedRateString = "${modum.tokenapp.email.send-email-interval}") void sendEmail(); }
@Test public void testSendEmailTask() throws IOException, URISyntaxException { FileQueueService fileQueueService = new FileQueueService(getTempFilePath(), objectMapper); fileQueueService.addConfirmationEmail(new Investor().setEmail(INVESTOR_EMAIL), new URI(CONFIRMATION_EMAIL_URI)); Email email = fileQueueService.peekEm...
Etherscan { public BigInteger getBalance(String address) throws IOException { String s = "https: "?module=account" + "&action=balance" + "&address=" + address + "&tag=latest" + "&apikey="+apiKey; HttpHeaders headers = new HttpHeaders(); headers.set("User-Agent", options.getUserAgent()); ResponseEntity<String> res = res...
@Test public void testConnect1() throws IOException { String balance = etherscan.getBalance("0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae").toString(); System.out.println("balance: "+balance); }
Etherscan { public BigInteger get20Balances(String... contract) throws IOException { return get20Balances(Arrays.asList(contract)); } BigInteger getBalance(String address); List<Triple<Date,Long,Long>> getTxEth(String address); BigInteger get20Balances(String... contract); BigInteger get20Balances(List<String> contrac...
@Test public void testConnect2() throws IOException { String balance = etherscan.get20Balances("0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae", "0x25d96310cd6694d88b9c6803be09511597c0a630").toString(); System.out.println("balance: "+balance); }
Etherscan { public long getCurrentBlockNr() throws IOException { String s = "https: "?module=proxy" + "&action=eth_blockNumber" + "&apikey="+apiKey; HttpHeaders headers = new HttpHeaders(); headers.set("User-Agent", options.getUserAgent()); ResponseEntity<String> res = restTemplate.exchange(s, HttpMethod.GET, new HttpE...
@Test public void testBlockNr() throws IOException { long bl1 = blockr.getCurrentBlockNr(); long bl2 = etherscan.getCurrentBlockNr(); System.out.println("ret: "+bl1 +"/"+bl2); }
BerIdentifier { public int encode(BerByteArrayOutputStream berOStream) throws IOException { for (int i = (identifier.length - 1); i >= 0; i--) { berOStream.write(identifier[i]); } return identifier.length; } BerIdentifier(int identifierClass, int primitive, int tagNumber); BerIdentifier(); int encode(BerByteArrayOutpu...
@Test public void twoByteEncoding() throws IOException { BerByteArrayOutputStream berBAOStream = new BerByteArrayOutputStream(50); BerIdentifier berIdentifier = new BerIdentifier(BerIdentifier.APPLICATION_CLASS, BerIdentifier.PRIMITIVE, 31); int length = berIdentifier.encode(berBAOStream); Assert.assertEquals(2, length...
BerInteger { public int encode(BerByteArrayOutputStream berOStream, boolean explicit) throws IOException { int codeLength; if (code != null) { codeLength = code.length; for (int i = code.length - 1; i >= 0; i--) { berOStream.write(code[i]); } } else { codeLength = 1; while (val > (Math.pow(2, (8 * codeLength) - 1) - 1)...
@Test public void implicitEncoding7() throws IOException { BerByteArrayOutputStream berBAOStream = new BerByteArrayOutputStream(50); IntegerUnivPrim testInteger = new IntegerUnivPrim(-129); int length = testInteger.encode(berBAOStream, false); Assert.assertEquals(3, length); byte[] expectedBytes = new byte[] { 0x02, (b...
BerInteger { public int decode(InputStream iStream, boolean explicit) throws IOException { int codeLength = 0; if (explicit) { codeLength += id.decodeAndCheck(iStream); } BerLength length = new BerLength(); codeLength += length.decode(iStream); if (length.val < 1 || length.val > 8) { throw new IOException("Decoded leng...
@Test public void explicitDecoding() throws IOException { byte[] byteCode = new byte[] { 0x02, 0x01, 0x33 }; ByteArrayInputStream berInputStream = new ByteArrayInputStream(byteCode); BerInteger asn1Integer = new BerInteger(); asn1Integer.decode(berInputStream, true); Assert.assertEquals(51, asn1Integer.val); } @Test pu...
BerOctetString { public int encode(BerByteArrayOutputStream berOStream, boolean explicit) throws IOException { berOStream.write(octetString); int codeLength = octetString.length; codeLength += BerLength.encodeLength(berOStream, codeLength); if (explicit) { codeLength += id.encode(berOStream); } return codeLength; } Ber...
@Test public void explicitEncoding() throws IOException { BerByteArrayOutputStream berStream = new BerByteArrayOutputStream(50); byte[] byteArray = new byte[] { 0x01, 0x02, 0x03 }; BerOctetString asn1OctetString = new BerOctetString(byteArray); int length = asn1OctetString.encode(berStream, true); Assert.assertEquals(5...
BerOctetString { public int decode(InputStream iStream, boolean explicit) throws IOException { int codeLength = 0; if (explicit) { codeLength += id.decodeAndCheck(iStream); } BerLength length = new BerLength(); codeLength += length.decode(iStream); octetString = new byte[length.val]; if (length.val != 0) { if (iStream....
@Test public void explicitDecoding() throws IOException { byte[] byteCode = new byte[] { 0x04, 0x00 }; ByteArrayInputStream berInputStream = new ByteArrayInputStream(byteCode); BerOctetString asn1OctetString = new BerOctetString(); asn1OctetString.decode(berInputStream, true); Assert.assertEquals(0, asn1OctetString.oct...
BerObjectIdentifier { public int encode(BerByteArrayOutputStream berOStream, boolean explicit) throws IOException { int codeLength; if (code != null) { codeLength = code.length; for (int i = code.length - 1; i >= 0; i--) { berOStream.write(code[i]); } } else { int firstSubidentifier = 40 * objectIdentifierComponents[0]...
@Test public void explicitEncoding() throws IOException { BerByteArrayOutputStream berBAOStream = new BerByteArrayOutputStream(50); BerObjectIdentifier oi = new BerObjectIdentifier(objectIdentifierComponents); int length = oi.encode(berBAOStream, true); Assert.assertEquals(7, length); Assert.assertArrayEquals(expectedB...
BerLength { public static int encodeLength(BerByteArrayOutputStream berOStream, int length) throws IOException { if (length <= 127) { berOStream.write((byte) length); return 1; } else { int numLengthBytes = 1; while (((int) (Math.pow(2, 8 * numLengthBytes) - 1)) < length) { numLengthBytes++; } for (int i = 0; i < numLe...
@Test public void encodeLength() throws IOException { BerByteArrayOutputStream berOStream = new BerByteArrayOutputStream(50); int codedLength = BerLength.encodeLength(berOStream, 128); Assert.assertEquals(2, codedLength); byte[] expectedBytes = new byte[] { (byte) 0x81, (byte) 128 }; Assert.assertArrayEquals(expectedBy...
BerObjectIdentifier { public int decode(InputStream iStream, boolean explicit) throws IOException { int codeLength = 0; if (explicit) { codeLength += id.decodeAndCheck(iStream); } BerLength length = new BerLength(); codeLength += length.decode(iStream); if (length.val == 0) { objectIdentifierComponents = new int[0]; re...
@Test public void explicitDecoding() throws IOException { ByteArrayInputStream berInputStream = new ByteArrayInputStream(expectedBytes); BerObjectIdentifier oi = new BerObjectIdentifier(); oi.decode(berInputStream, true); Assert.assertArrayEquals(objectIdentifierComponents, oi.objectIdentifierComponents); ByteArrayInpu...
BerLength { public int decode(InputStream iStream) throws IOException { val = iStream.read(); int length = 1; if ((val & 0x80) != 0) { int lengthLength = val & 0x7f; if (lengthLength == 0) { val = -1; return 1; } if (lengthLength > 4) { throw new IOException("Length is out of bound!"); } val = 0; byte[] byteCode = new ...
@Test public void explicitDecoding() throws IOException { byte[] byteCode = new byte[] { (byte) 0x81, (byte) 128 }; ByteArrayInputStream berInputStream = new ByteArrayInputStream(byteCode); BerLength berLength = new BerLength(); berLength.decode(berInputStream); Assert.assertEquals(128, berLength.val); }
Functions { public static <T> List<T> myFilter(List<T> list, MyPredicate<T> myPredicate) { ArrayList<T> result = new ArrayList<>(); for (T t : list) { if (myPredicate.test(t)) result.add(t); } return result; } static List<T> myFilter(List<T> list, MyPredicate<T> myPredicate); static List<R> myMap(List<T> list, MyFunct...
@Test public void testMyFilter() { List<Integer> numbers = Arrays.asList(4, 5, 7, 8, 10, 11, 14, 15); List<Integer> result = Functions.myFilter(numbers, item -> item % 2 == 0); assertEquals(Arrays.asList(4, 8, 10, 14), result); } @Test public void testClosuresAvoidRepeats() { List<String> names = Arrays.asList("Foo", "...
Functions { public static <T> List<T> myGenerate(MySupplier<T> supplier, int count) { List<T> result = new ArrayList<>(); for (int i = 0; i < count; i++) { result.add(supplier.get()); } return result; } static List<T> myFilter(List<T> list, MyPredicate<T> myPredicate); static List<R> myMap(List<T> list, MyFunction<T, ...
@Test public void testMyGenerate() { List<LocalDateTime> localDateTimes = Functions.myGenerate(() -> { try { Thread.sleep(1000); } catch (InterruptedException e) { } return LocalDateTime.now(); }, 10); System.out.println(localDateTimes); }
Functions { public static <T, R> List<R> myMap(List<T> list, MyFunction<T, R> myFunction) { ArrayList<R> result = new ArrayList<>(); for (T t : list) { result.add(myFunction.apply(t)); } return result; } static List<T> myFilter(List<T> list, MyPredicate<T> myPredicate); static List<R> myMap(List<T> list, MyFunction<T,...
@Test public void testMyMap() { List<Integer> numbers = Arrays.asList(4, 5, 7, 8); List<Integer> mapped = Functions.myMap(numbers, t -> t + 2); assertEquals(Arrays.asList(6, 7, 9, 10), mapped); } @Test public void testMethodReferenceAStaticMethod() { List<Integer> numbers = Arrays.asList(2, 4, 5, 1, 9, 15, 19, 21, 33, ...
Functions { public static <T, R> List<R> myFlatMap(List<T> list, MyFunction<T, List<R>> myFunction) { ArrayList<R> result = new ArrayList<>(); for (T t : list) { List<R> application = myFunction.apply(t); result.addAll(application); } return result; } static List<T> myFilter(List<T> list, MyPredicate<T> myPredicate); ...
@Test public void testMyFlatMap() { List<Integer> numbers = Arrays.asList(4, 5, 7, 8); List<Integer> mapped = Functions.myFlatMap(numbers, t -> List.of(t - 1, t, t + 1)); assertEquals(Arrays.asList(3, 4, 5, 4, 5, 6, 6, 7, 8, 7, 8, 9), mapped); }
Functions { public static <T> void myForEach(List<T> list, MyConsumer<T> myConsumer) { for (T t : list) { myConsumer.accept(t); } } static List<T> myFilter(List<T> list, MyPredicate<T> myPredicate); static List<R> myMap(List<T> list, MyFunction<T, R> myFunction); static List<R> myFlatMap(List<T> list, MyFunction<T, Li...
@Test public void testMyForEach() { List<Integer> numbers = Arrays.asList(4, 5, 7, 8); Functions.myForEach(numbers, new MyConsumer<Integer>() { @Override public void accept(Integer x) { System.out.println(x); } }); }
WeChatUtils { public static String joinPath(final String firstPath, final String secondPath) { Validate.notEmpty(firstPath); Validate.notEmpty(secondPath); final String tmp1 = firstPath.endsWith("/") ? firstPath.substring(0, firstPath.length() - 1) : firstPath; final String tmp2 = secondPath.startsWith("/") ? (tmp1 + s...
@Test public void joinPath() { assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: }
WeChatPayRestTemplateClient implements WeChatPayClient { @Override public UnifiedOrderResponse unifiedOrder( final UnifiedOrderRequest request) throws WeChatPayException { Objects.requireNonNull(request); return postForEntity( WeChatPayClient.UNIFIED_ORDER_PATH, request, UnifiedOrderResponse.class) .getBody(); } WeChat...
@Test public void unifiedOrder() { stubFor(post(urlEqualTo(WeChatPayClient.UNIFIED_ORDER_PATH)) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", MediaType.APPLICATION_XML_VALUE) .withBody("<xml><return_code>SUCCESS</return_code><result_code>SUCCESS</result_code></xml>"))); WeChatPayConfigurator.DEFA...
WeChatPayRestTemplateClient implements WeChatPayClient { @Override public OrderQueryResponse orderQuery( final OrderQueryRequest request) throws WeChatPayException { Objects.requireNonNull(request); return postForEntity( WeChatPayClient.ORDER_QUERY_PATH, request, OrderQueryResponse.class) .getBody(); } WeChatPayRestTem...
@Test public void orderQuery() { }
WeChatMpController { @GetMapping(path = "${wechat.mp.authorize-code-path:" + WeChatMpProperties.AUTHORIZE_CODE_PATH + '}') public void authorizeCode( @RequestParam("code") final String code) { final WeChatMpAccessTokenResponse accessTokenResponse = this.weChatMpClient.accessToken(code); if (accessTokenResponse.isSucces...
@Test public void authorizeCode() throws Exception { final WeChatMpAccessTokenResponse accessTokenResponse = new WeChatMpAccessTokenResponse(); accessTokenResponse.setErrCode("0"); given(this.weChatMpClient.accessToken("code")).willReturn(accessTokenResponse); this.mvc.perform(get(WeChatMpProperties.AUTHORIZE_CODE_PATH...
WeChatMpAutoConfiguration { @Bean @ConditionalOnMissingBean public WeChatMpController weChatMpController(final WeChatMpClient weChatMpClient, final ApplicationEventPublisher publisher) { return new WeChatMpController(this.weChatMpProperties, weChatMpClient, publisher); } WeChatMpAutoConfiguration(final WeChatMpProperti...
@Test public void weChatMpController() throws Exception { ClassPool.getDefault().makeClass("cn.javaer.wechat.spring.boot.starter.mp.ConditionalOnClassTrigger").toClass(); try (AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext()) { context.register(WeChatMpAutoConfiguration.class)...
WeChatPayUtils { @NotNull public static String generateSign( @NotNull final BasePayRequest request, @NotNull final String mchKey) { return generateSign(signParamsFrom(request), mchKey); } @NotNull static String generateSign( @NotNull final BasePayRequest request, @NotNull final String mchKey); @NotNull sta...
@Test public void sign() { final UnifiedOrderResponse response = new UnifiedOrderResponse(); response.setReturnCode("SUCCESS"); response.setReturnMsg("OK"); response.setAppid("wx2421b1c4370ec43b"); response.setMchId("10000100"); response.setNonceStr("IITRi8Iabbblz1Jc"); response.setResultCode("SUCCESS"); response.setPr...
WeChatPayUtils { public static <T> Map<String, T> beansMapFrom( @NotNull final SortedMap<String, String> params, @NotNull final Map<String, BiConsumer<String, T>> mapping, @NotNull final Supplier<T> newT) { final Map<String, T> rtMap = new HashMap<>(); for (final Map.Entry<String, String> entry : params.entrySet()) { f...
@Test public void beansMapFrom() { final SortedMap<String, String> params = new TreeMap<>(); params.put("coupon_refund_id_0", "BC884153761883FE608EA956BD05A6F5"); params.put("coupon_type_0", "CASH"); params.put("coupon_refund_fee_0", "100"); params.put("coupon_refund_id_1", "16BE80B8FD1044069950ADAEDEB812C5"); params.p...
NotifyResult extends BasePayResponse { @Override public void beforeSign() { if (null == this.coupons && null != this.otherParams) { this.coupons = WeChatPayUtils.couponsFrom(this.otherParams); } } @Override void beforeSign(); }
@Test public void testParse() { final String xml = WeChatTestUtils.readClassPathFileToUTFString("/WeChatPayNotifyResult.xml", this.getClass()); final NotifyResult notifyResult = WeChatTestUtils.jaxbUnmarshal(xml, NotifyResult.class); assertThat(notifyResult) .hasAppid("wx2421b1c4370ec43b") .hasAttach("支付测试") .hasBankTy...
RefundQueryResponse extends BasePayResponse { @Override public void beforeSign() { if (null == this.refunds && null != this.otherParams) { final Map<String, Refund> refundsMap = WeChatPayUtils.beansMapFrom(this.otherParams, createRefundMapping(), Refund::new); initCoupons(refundsMap); this.refunds = new ArrayList<>(ref...
@Test public void beforeSign() { final String xmlStr = WeChatTestUtils.readClassPathFileToUTFString("/WeChatPayRefundQueryResponse.xml", this.getClass()); final RefundQueryResponse response = WeChatTestUtils.jaxbUnmarshal(xmlStr, RefundQueryResponse.class); assertThat(response) .hasReturnCode("SUCCESS") .hasResultCode(...
WeChatMpResponse { @JsonAnySetter protected void setOtherProperties(final String name, final String value) { this.otherProperties.put(name, value); } boolean isSuccessful(); }
@Test public void setOtherProperties() throws Exception { final ObjectMapper mapper = new ObjectMapper(); final Demo demo = mapper.readValue("{\"errcode\":\"d1\",\"any1\":\"any1\",\"any2\":\"any2\"}", Demo.class); Assert.assertEquals("d1", demo.getErrCode()); Assert.assertEquals("any1", demo.getOtherProperties().get("a...
WeChatMpUtils { public static String generateAuthorizeUrl( @NotNull final String appId, @NotNull final String redirectUri, @NotNull final AuthorizeScope scope, @NotNull final String state) { return "https: + "&redirect_uri=" + WeChatUtils.urlEncode(redirectUri) + "&response_type=code&scope=" + scope.getScope() + "&stat...
@Test public void generateAuthorizeUrl() { final String authorizeUrl = WeChatMpUtils.generateAuthorizeUrl( "wx520c15f417810387", "https: AuthorizeScope.BASE, "123"); final String expected = "https: assertEquals(expected, authorizeUrl); } @Test public void generateAuthorizeUrlNoState() { final String authorizeUrl = WeCh...
WeChatPayAutoConfiguration { @Bean @ConditionalOnMissingBean public WeChatPayClient weChatPayClient( @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") @Autowired(required = false) RestTemplate restTemplate) { if (null == restTemplate) { restTemplate = new RestTemplate(); } return new WeChatPayRestTempl...
@Test public void weChatPayClient() throws Exception { ClassPool.getDefault().makeClass("cn.javaer.wechat.spring.boot.starter.pay.ConditionalOnClassTrigger").toClass(); try (AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext()) { context.register(WeChatPayAutoConfiguration.class);...
BerLength implements Serializable { public static int encodeLength(OutputStream reverseOS, int length) throws IOException { if (length <= 127) { reverseOS.write(length); return 1; } if (length <= 255) { reverseOS.write(length); reverseOS.write(0x81); return 2; } if (length <= 65535) { reverseOS.write(length); reverseOS...
@Test public void encodeLength() throws IOException { ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(50); int codedLength = BerLength.encodeLength(os, 128); assertEquals(2, codedLength); byte[] expectedBytes = new byte[] {(byte) 0x81, (byte) 128}; assertArrayEquals(expectedBytes, os.getArray()); } @...
BerInteger implements Serializable, BerType { @Override public int encode(OutputStream reverseOS) throws IOException { return encode(reverseOS, true); } BerInteger(); BerInteger(byte[] code); BerInteger(BigInteger val); BerInteger(long val); @Override int encode(OutputStream reverseOS); int encode(OutputStream rever...
@Test public void implicitEncoding5() throws IOException { ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50); IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(128)); int length = testInteger.encode(berBAOStream, false); assertEquals(3, length); byte[] expectedBytes = n...
BerOctetString implements Serializable, BerType { @Override public int encode(OutputStream reverseOS) throws IOException { return encode(reverseOS, true); } BerOctetString(); BerOctetString(byte[] value); @Override int encode(OutputStream reverseOS); int encode(OutputStream reverseOS, boolean withTag); @Override int d...
@Test public void explicitEncoding() throws IOException { ReverseByteArrayOutputStream berStream = new ReverseByteArrayOutputStream(50); byte[] byteArray = new byte[] {0x01, 0x02, 0x03}; BerOctetString asn1OctetString = new BerOctetString(byteArray); int length = asn1OctetString.encode(berStream, true); assertEquals(5,...
BerOctetString implements Serializable, BerType { @Override public int decode(InputStream is) throws IOException { return decode(is, true); } BerOctetString(); BerOctetString(byte[] value); @Override int encode(OutputStream reverseOS); int encode(OutputStream reverseOS, boolean withTag); @Override int decode(InputStre...
@Test public void explicitDecoding() throws IOException { byte[] byteCode = new byte[] {0x04, 0x00}; ByteArrayInputStream berInputStream = new ByteArrayInputStream(byteCode); BerOctetString asn1OctetString = new BerOctetString(); asn1OctetString.decode(berInputStream, true); assertEquals(0, asn1OctetString.value.length...
BerOctetString implements Serializable, BerType { @Override public String toString() { return HexString.fromBytes(value); } BerOctetString(); BerOctetString(byte[] value); @Override int encode(OutputStream reverseOS); int encode(OutputStream reverseOS, boolean withTag); @Override int decode(InputStream is); int decode...
@Test public void toStringTest() { BerOctetString octetString = new BerOctetString(new byte[] {1, 2, (byte) 0xa0}); assertEquals("0102A0", octetString.toString()); }
BerObjectIdentifier implements Serializable, BerType { @Override public int encode(OutputStream reverseOS) throws IOException { return encode(reverseOS, true); } BerObjectIdentifier(); BerObjectIdentifier(byte[] code); BerObjectIdentifier(int[] value); @Override int encode(OutputStream reverseOS); int encode(OutputSt...
@Test public void explicitEncoding() throws IOException { ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50); BerObjectIdentifier oi = new BerObjectIdentifier(objectIdentifierComponents); int length = oi.encode(berBAOStream, true); assertEquals(7, length); assertArrayEquals(expectedBytes, ...
BerObjectIdentifier implements Serializable, BerType { @Override public int decode(InputStream is) throws IOException { return decode(is, true); } BerObjectIdentifier(); BerObjectIdentifier(byte[] code); BerObjectIdentifier(int[] value); @Override int encode(OutputStream reverseOS); int encode(OutputStream reverseOS,...
@Test public void explicitDecoding() throws IOException { ByteArrayInputStream berInputStream = new ByteArrayInputStream(expectedBytes); BerObjectIdentifier oi = new BerObjectIdentifier(); oi.decode(berInputStream, true); assertArrayEquals(objectIdentifierComponents, oi.value); ByteArrayInputStream berInputStream2 = ne...
BerGeneralizedTime extends BerVisibleString { @Override public int encode(OutputStream reverseOS, boolean withTag) throws IOException { int codeLength = super.encode(reverseOS, false); if (withTag) { codeLength += tag.encode(reverseOS); } return codeLength; } BerGeneralizedTime(); BerGeneralizedTime(byte[] value); Be...
@Test public void explicitEncoding() throws IOException { ReverseByteArrayOutputStream berStream = new ReverseByteArrayOutputStream(50); byte[] byteArray = new byte[] {0x01, 0x02, 0x03}; BerGeneralizedTime berGeneralizedTime = new BerGeneralizedTime(byteArray); int length = berGeneralizedTime.encode(berStream, true); a...
BerBitString implements Serializable, BerType { @Override public String toString() { StringBuilder sb = new StringBuilder(); for (boolean bit : getValueAsBooleans()) { if (bit) { sb.append('1'); } else { sb.append('0'); } } return sb.toString(); } BerBitString(); BerBitString(byte[] value, int numBits); BerBitString(...
@Test public void toStringTest() { BerBitString bitString = new BerBitString(new byte[] {1, 2, 7}, 23); assertEquals("00000001000000100000011", bitString.toString()); } @Test public void toString2Test() { BerBitString bitString = new BerBitString( new boolean[] { false, false, false, false, false, false, false, true, f...
BerLength implements Serializable { public int decode(InputStream is) throws IOException { val = is.read(); if (val < 128) { if (val == -1) { throw new EOFException("Unexpected end of input stream."); } return 1; } int lengthLength = val & 0x7f; if (lengthLength == 0) { val = -1; return 1; } if (lengthLength > 4) { thr...
@Test public void explicitDecoding() throws IOException { byte[] byteCode = new byte[] {(byte) 0x81, (byte) 128}; ByteArrayInputStream berInputStream = new ByteArrayInputStream(byteCode); BerLength berLength = new BerLength(); berLength.decode(berInputStream); assertEquals(128, berLength.val); }
PrimaryMetaStore extends AbstractMetaStore { @Override public FederationType getFederationType() { return FederationType.PRIMARY; } PrimaryMetaStore(); PrimaryMetaStore( String name, String remoteMetaStoreUris, AccessControlType accessControlType, String... writableDatabaseWhitelist); PrimaryM...
@Test public void testFederationType() { assertThat(metaStore.getFederationType(), is(FederationType.PRIMARY)); }
MetaStoreMappingDecorator implements MetaStoreMapping { @Override public String getMetastoreMappingName() { return metaStoreMapping.getMetastoreMappingName(); } MetaStoreMappingDecorator(MetaStoreMapping metaStoreMapping); @Override String transformOutboundDatabaseName(String databaseName); @Override List<String> trans...
@Test public void getMetastoreMappingName() throws Exception { when(metaStoreMapping.getMetastoreMappingName()).thenReturn("Name"); String result = decorator.getMetastoreMappingName(); assertThat(result, is("Name")); }
MetaStoreMappingDecorator implements MetaStoreMapping { @Override public boolean isAvailable() { return metaStoreMapping.isAvailable(); } MetaStoreMappingDecorator(MetaStoreMapping metaStoreMapping); @Override String transformOutboundDatabaseName(String databaseName); @Override List<String> transformOutboundDatabaseNam...
@Test public void isAvailable() throws Exception { when(metaStoreMapping.isAvailable()).thenReturn(true); boolean result = decorator.isAvailable(); assertThat(result, is(true)); }
MetaStoreMappingDecorator implements MetaStoreMapping { @Override public String transformInboundDatabaseName(String databaseName) { return metaStoreMapping.transformInboundDatabaseName(databaseName); } MetaStoreMappingDecorator(MetaStoreMapping metaStoreMapping); @Override String transformOutboundDatabaseName(String da...
@Test public void transformInboundDatabaseName() throws Exception { when(metaStoreMapping.transformInboundDatabaseName("db")).thenReturn("trans_db"); String result = decorator.transformInboundDatabaseName("db"); assertThat(result, is("trans_db")); }
MetaStoreMappingDecorator implements MetaStoreMapping { @Override public String transformOutboundDatabaseName(String databaseName) { return metaStoreMapping.transformOutboundDatabaseName(databaseName); } MetaStoreMappingDecorator(MetaStoreMapping metaStoreMapping); @Override String transformOutboundDatabaseName(String ...
@Test public void transformOutboundDatabaseName() throws Exception { when(metaStoreMapping.transformOutboundDatabaseName("db")).thenReturn("trans_db"); String result = decorator.transformOutboundDatabaseName("db"); assertThat(result, is("trans_db")); }
MetaStoreMappingDecorator implements MetaStoreMapping { @Override public Database transformOutboundDatabase(Database database) { return metaStoreMapping.transformOutboundDatabase(database); } MetaStoreMappingDecorator(MetaStoreMapping metaStoreMapping); @Override String transformOutboundDatabaseName(String databaseName...
@Test public void transformOutboundDatabase() throws Exception { Database database = new Database(); database.setName("a"); Database expected = new Database(); expected.setName("b"); when(metaStoreMapping.transformOutboundDatabase(database)).thenReturn(expected); Database result = decorator.transformOutboundDatabase(da...
MetaStoreMappingImpl implements MetaStoreMapping { @Override public String transformOutboundDatabaseName(String databaseName) { return databaseName.toLowerCase(Locale.ROOT); } MetaStoreMappingImpl( String databasePrefix, String name, CloseableThriftHiveMetastoreIface client, AccessControlHandler...
@Test public void transformOutboundDatabaseName() { assertThat(metaStoreMapping.transformOutboundDatabaseName("My_Database"), is("my_database")); }
MetaStoreMappingImpl implements MetaStoreMapping { @Override public Database transformOutboundDatabase(Database database) { database.setName(transformOutboundDatabaseName(database.getName())); return database; } MetaStoreMappingImpl( String databasePrefix, String name, CloseableThriftHiveMetastoreIfac...
@Test public void transformOutboundDatabase() { when(database.getName()).thenReturn("My_Database"); Database outboundDatabase = metaStoreMapping.transformOutboundDatabase(database); assertThat(outboundDatabase, is(sameInstance(database))); verify(outboundDatabase).setName("my_database"); }
MetaStoreMappingImpl implements MetaStoreMapping { @Override public String transformInboundDatabaseName(String databaseName) { return databaseName.toLowerCase(Locale.ROOT); } MetaStoreMappingImpl( String databasePrefix, String name, CloseableThriftHiveMetastoreIface client, AccessControlHandler ...
@Test public void transformInboundDatabaseName() { assertThat(metaStoreMapping.transformInboundDatabaseName("My_Database"), is("my_database")); } @Test public void transformInboundDatabaseNameWithoutPrefixReturnsDatabase() { assertThat(metaStoreMapping.transformInboundDatabaseName("no_prefix_My_Database"), is("no_prefi...
MetaStoreMappingImpl implements MetaStoreMapping { @Override public String getDatabasePrefix() { return databasePrefix; } MetaStoreMappingImpl( String databasePrefix, String name, CloseableThriftHiveMetastoreIface client, AccessControlHandler accessControlHandler, ConnectionType connection...
@Test public void getDatabasePrefix() { assertThat(metaStoreMapping.getDatabasePrefix(), is(DATABASE_PREFIX)); }
AbstractMetaStore { public static FederatedMetaStore newFederatedInstance(String name, String remoteMetaStoreUris) { return new FederatedMetaStore(name, remoteMetaStoreUris); } AbstractMetaStore(); AbstractMetaStore(String name, String remoteMetaStoreUris, AccessControlType accessControlType); AbstractMetaStore( ...
@Test public void newFederatedInstance() { FederatedMetaStore federatedMetaStore = AbstractMetaStore.newFederatedInstance(name, remoteMetaStoreUri); assertThat(federatedMetaStore.getName(), is(name)); assertThat(federatedMetaStore.getRemoteMetaStoreUris(), is(remoteMetaStoreUri)); }
MetaStoreMappingImpl implements MetaStoreMapping { @Override public String getMetastoreMappingName() { return name; } MetaStoreMappingImpl( String databasePrefix, String name, CloseableThriftHiveMetastoreIface client, AccessControlHandler accessControlHandler, ConnectionType connectionType...
@Test public void getMetastoreMappingNameSameAsPrefix() { assertThat(metaStoreMapping.getMetastoreMappingName(), is(NAME)); }
MetaStoreMappingImpl implements MetaStoreMapping { @Override public void close() throws IOException { client.close(); } MetaStoreMappingImpl( String databasePrefix, String name, CloseableThriftHiveMetastoreIface client, AccessControlHandler accessControlHandler, ConnectionType connectionTy...
@Test public void close() throws IOException { metaStoreMapping.close(); verify(client).close(); }
MetaStoreMappingImpl implements MetaStoreMapping { @Override public boolean isAvailable() { try { boolean isOpen = client.isOpen(); if (isOpen && connectionType == ConnectionType.TUNNELED) { client.getStatus(); } return isOpen; } catch (Exception e) { log.error("Metastore Mapping {} unavailable", name, e); return false...
@Test public void isAvailable() { when(client.isOpen()).thenReturn(true); assertThat(metaStoreMapping.isAvailable(), is(true)); } @Test public void isNotAvailable() { when(client.isOpen()).thenReturn(false); assertThat(metaStoreMapping.isAvailable(), is(false)); } @Test public void isAvailableTunnelled() throws Excepti...
MetaStoreMappingImpl implements MetaStoreMapping { @Override public MetaStoreMapping checkWritePermissions(String databaseName) { if (!accessControlHandler.hasWritePermission(databaseName)) { throw new NotAllowedException( "You cannot perform this operation on the virtual database '" + databaseName + "'."); } return th...
@Test public void checkWritePermissions() { String databaseName = "db"; when(accessControlHandler.hasWritePermission(databaseName)).thenReturn(true); assertThat(metaStoreMapping.checkWritePermissions(databaseName), is(metaStoreMapping)); } @Test(expected = NotAllowedException.class) public void checkWritePermissionsThr...
MetaStoreMappingImpl implements MetaStoreMapping { @Override public void createDatabase(Database database) throws AlreadyExistsException, InvalidObjectException, MetaException, TException { if (accessControlHandler.hasCreatePermission()) { getClient().create_database(database); accessControlHandler.databaseCreatedNotif...
@Test public void createDatabase() throws Exception { when(database.getName()).thenReturn("db"); when(accessControlHandler.hasCreatePermission()).thenReturn(true); metaStoreMapping.createDatabase(database); verify(client).create_database(database); verify(accessControlHandler).databaseCreatedNotification("db"); } @Test...
AbstractMetaStore { public static PrimaryMetaStore newPrimaryInstance( String name, String remoteMetaStoreUris, AccessControlType accessControlType) { return new PrimaryMetaStore(name, remoteMetaStoreUris, accessControlType); } AbstractMetaStore(); AbstractMetaStore(String name, String remoteMetaStoreUris, AccessContr...
@Test public void newPrimaryInstance() { AccessControlType access = AccessControlType.READ_AND_WRITE_AND_CREATE; PrimaryMetaStore primaryMetaStore = AbstractMetaStore.newPrimaryInstance(name, remoteMetaStoreUri, access); assertThat(primaryMetaStore.getName(), is(name)); assertThat(primaryMetaStore.getRemoteMetaStoreUri...
MetaStoreMappingImpl implements MetaStoreMapping { @Override public long getLatency() { return latency; } MetaStoreMappingImpl( String databasePrefix, String name, CloseableThriftHiveMetastoreIface client, AccessControlHandler accessControlHandler, ConnectionType connectionType, long...
@Test public void getLatency() { assertThat(metaStoreMapping.getLatency(), is(LATENCY)); }
DatabaseMappingImpl implements DatabaseMapping { @Override public Table transformOutboundTable(Table table) { table.setDbName(metaStoreMapping.transformOutboundDatabaseName(table.getDbName())); if (table.isSetViewExpandedText()) { try { log.debug("Transforming ViewExpandedText: {}", table.getViewExpandedText()); table ...
@Test public void transformOutboundTable() throws Exception { Table table = new Table(); table.setDbName(DB_NAME); Table result = databaseMapping.transformOutboundTable(table); assertThat(result, is(sameInstance(table))); assertThat(result.getDbName(), is(OUT_DB_NAME)); assertThat(result.getViewExpandedText(), nullValu...
DatabaseMappingImpl implements DatabaseMapping { @Override public Table transformInboundTable(Table table) { table.setDbName(metaStoreMapping.transformInboundDatabaseName(table.getDbName())); return table; } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping queryMapping); @Override Table transformOutb...
@Test public void transformInboundTable() throws Exception { Table table = new Table(); table.setDbName(DB_NAME); Table result = databaseMapping.transformInboundTable(table); assertThat(result, is(sameInstance(table))); assertThat(result.getDbName(), is(IN_DB_NAME)); }
DatabaseMappingImpl implements DatabaseMapping { @Override public Partition transformOutboundPartition(Partition partition) { partition.setDbName(metaStoreMapping.transformOutboundDatabaseName(partition.getDbName())); return partition; } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping queryMapping);...
@Test public void transformOutboundPartition() throws Exception { Partition result = databaseMapping.transformOutboundPartition(partition); assertThat(result, is(sameInstance(partition))); assertThat(result.getDbName(), is(OUT_DB_NAME)); }
DatabaseMappingImpl implements DatabaseMapping { @Override public Partition transformInboundPartition(Partition partition) { partition.setDbName(metaStoreMapping.transformInboundDatabaseName(partition.getDbName())); return partition; } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping queryMapping); @...
@Test public void transformInboundPartition() throws Exception { Partition result = databaseMapping.transformInboundPartition(partition); assertThat(result, is(sameInstance(partition))); assertThat(result.getDbName(), is(IN_DB_NAME)); }
DatabaseMappingImpl implements DatabaseMapping { @Override public Index transformOutboundIndex(Index index) { index.setDbName(metaStoreMapping.transformOutboundDatabaseName(index.getDbName())); return index; } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping queryMapping); @Override Table transformOu...
@Test public void transformOutboundIndex() throws Exception { Index result = databaseMapping.transformOutboundIndex(index); assertThat(result, is(sameInstance(index))); assertThat(result.getDbName(), is(OUT_DB_NAME)); }
DatabaseMappingImpl implements DatabaseMapping { @Override public Index transformInboundIndex(Index index) { index.setDbName(metaStoreMapping.transformInboundDatabaseName(index.getDbName())); return index; } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping queryMapping); @Override Table transformOutb...
@Test public void transformInboundIndex() throws Exception { Index result = databaseMapping.transformInboundIndex(index); assertThat(result, is(sameInstance(index))); assertThat(result.getDbName(), is(IN_DB_NAME)); }
DatabaseMappingImpl implements DatabaseMapping { @Override public Function transformOutboundFunction(Function function) { function.setDbName(metaStoreMapping.transformOutboundDatabaseName(function.getDbName())); return function; } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping queryMapping); @Overr...
@Test public void transformOutboundFunction() throws Exception { Function function = new Function(); function.setDbName(DB_NAME); Function result = databaseMapping.transformOutboundFunction(function); assertThat(result, is(sameInstance(function))); assertThat(result.getDbName(), is(OUT_DB_NAME)); }
FederatedMetaStore extends AbstractMetaStore { @Override public FederationType getFederationType() { return FederationType.FEDERATED; } FederatedMetaStore(); FederatedMetaStore(String name, String remoteMetaStoreUris); FederatedMetaStore(String name, String remoteMetaStoreUris, AccessControlType accessControlType); ...
@Test public void testFederationType() { assertThat(metaStore.getFederationType(), is(FederationType.FEDERATED)); }
DatabaseMappingImpl implements DatabaseMapping { @Override public HiveObjectRef transformInboundHiveObjectRef(HiveObjectRef obj) { obj.setDbName(metaStoreMapping.transformInboundDatabaseName(obj.getDbName())); if (obj.getObjectType() == HiveObjectType.DATABASE) { obj.setObjectName(metaStoreMapping.transformInboundDatab...
@Test public void transformInboundHiveObjectRef() throws Exception { HiveObjectRef result = databaseMapping.transformInboundHiveObjectRef(hiveObjectRef); assertThat(result, is(sameInstance(hiveObjectRef))); assertThat(result.getDbName(), is(IN_DB_NAME)); assertThat(result.getObjectName(), is(IN_DB_NAME)); } @Test publi...
DatabaseMappingImpl implements DatabaseMapping { @Override public HiveObjectRef transformOutboundHiveObjectRef(HiveObjectRef obj) { obj.setDbName(metaStoreMapping.transformOutboundDatabaseName(obj.getDbName())); if (obj.getObjectType() == HiveObjectType.DATABASE) { obj.setObjectName(metaStoreMapping.transformOutboundDa...
@Test public void transformOutboundHiveObjectRef() throws Exception { HiveObjectRef result = databaseMapping.transformOutboundHiveObjectRef(hiveObjectRef); assertThat(result, is(sameInstance(hiveObjectRef))); assertThat(result.getDbName(), is(OUT_DB_NAME)); assertThat(result.getObjectName(), is(OUT_DB_NAME)); } @Test p...
DatabaseMappingImpl implements DatabaseMapping { @Override public PartitionSpec transformOutboundPartitionSpec(PartitionSpec partitionSpec) { partitionSpec.setDbName(metaStoreMapping.transformOutboundDatabaseName(partitionSpec.getDbName())); return partitionSpec; } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping,...
@Test public void transformOutboundPartitionSpec() throws Exception { PartitionSpec result = databaseMapping.transformOutboundPartitionSpec(partitionSpec); assertThat(result, is(sameInstance(partitionSpec))); assertThat(result.getDbName(), is(OUT_DB_NAME)); }
DatabaseMappingImpl implements DatabaseMapping { @Override public PartitionsStatsRequest transformInboundPartitionsStatsRequest(PartitionsStatsRequest request) { request.setDbName(metaStoreMapping.transformInboundDatabaseName(request.getDbName())); return request; } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping...
@Test public void transformInboundPartitionsStatsRequest() throws Exception { PartitionsStatsRequest partitionStatsRequest = new PartitionsStatsRequest(); partitionStatsRequest.setDbName(DB_NAME); PartitionsStatsRequest result = databaseMapping.transformInboundPartitionsStatsRequest(partitionStatsRequest); assertThat(r...
DatabaseMappingImpl implements DatabaseMapping { @Override public TableStatsRequest transformInboundTableStatsRequest(TableStatsRequest request) { request.setDbName(metaStoreMapping.transformInboundDatabaseName(request.getDbName())); return request; } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping ...
@Test public void transformInboundTableStatsRequest() throws Exception { TableStatsRequest tableStatsRequest = new TableStatsRequest(); tableStatsRequest.setDbName(DB_NAME); TableStatsRequest result = databaseMapping.transformInboundTableStatsRequest(tableStatsRequest); assertThat(result, is(sameInstance(tableStatsRequ...
DatabaseMappingImpl implements DatabaseMapping { @Override public PartitionsByExprRequest transformInboundPartitionsByExprRequest(PartitionsByExprRequest req) { req.setDbName(metaStoreMapping.transformInboundDatabaseName(req.getDbName())); return req; } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMappin...
@Test public void transformInboundPartitionsByExprRequest() throws Exception { PartitionsByExprRequest partitionsByExprRequest = new PartitionsByExprRequest(); partitionsByExprRequest.setDbName(DB_NAME); PartitionsByExprRequest result = databaseMapping.transformInboundPartitionsByExprRequest(partitionsByExprRequest); a...
DatabaseMappingImpl implements DatabaseMapping { @Override public PartitionsByExprResult transformOutboundPartitionsByExprResult(PartitionsByExprResult result) { result.setPartitions(transformOutboundPartitions(result.getPartitions())); return result; } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMappin...
@Test public void transformOutboundPartitionsByExprResult() throws Exception { PartitionsByExprResult partitionsByExprResult = new PartitionsByExprResult(); partitionsByExprResult.setPartitions(partitions); PartitionsByExprResult result = databaseMapping.transformOutboundPartitionsByExprResult(partitionsByExprResult); ...
DatabaseMappingImpl implements DatabaseMapping { @Override public Iface getClient() { return metaStoreMapping.getClient(); } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping queryMapping); @Override Table transformOutboundTable(Table table); @Override Partition transformOutboundPartition(Partition pa...
@Test public void getClient() throws Exception { databaseMapping.getClient(); verify(metastoreMapping).getClient(); }
FederatedMetaStore extends AbstractMetaStore { @Override public String getDatabasePrefix() { String prefix = super.getDatabasePrefix(); if (prefix == null) { prefix = getName() + "_"; } return prefix; } FederatedMetaStore(); FederatedMetaStore(String name, String remoteMetaStoreUris); FederatedMetaStore(String name, ...
@Test public void emptyDatabasePrefix() { metaStore.setDatabasePrefix(""); Set<ConstraintViolation<FederatedMetaStore>> violations = validator.validate(metaStore); assertThat(violations.size(), is(0)); assertThat(metaStore.getDatabasePrefix(), is("")); } @Test public void nonEmptyDatabasePrefix() { metaStore.setDatabas...
DatabaseMappingImpl implements DatabaseMapping { @Override public String transformOutboundDatabaseName(String databaseName) { return metaStoreMapping.transformOutboundDatabaseName(databaseName); } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping queryMapping); @Override Table transformOutboundTable(T...
@Test public void transformOutboundDatabaseName() throws Exception { assertThat(databaseMapping.transformOutboundDatabaseName(DB_NAME), is(OUT_DB_NAME)); }
DatabaseMappingImpl implements DatabaseMapping { @Override public String transformInboundDatabaseName(String databaseName) { return metaStoreMapping.transformInboundDatabaseName(databaseName); } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping queryMapping); @Override Table transformOutboundTable(Tab...
@Test public void transformInboundDatabaseName() throws Exception { assertThat(databaseMapping.transformInboundDatabaseName(DB_NAME), is(IN_DB_NAME)); }
DatabaseMappingImpl implements DatabaseMapping { @Override public Database transformOutboundDatabase(Database database) { return metaStoreMapping.transformOutboundDatabase(database); } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping queryMapping); @Override Table transformOutboundTable(Table table);...
@Test public void transformOutboundDatabase() throws Exception { databaseMapping.transformOutboundDatabase(database); verify(metastoreMapping).transformOutboundDatabase(database); }
DatabaseMappingImpl implements DatabaseMapping { @Override public String getDatabasePrefix() { return metaStoreMapping.getDatabasePrefix(); } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping queryMapping); @Override Table transformOutboundTable(Table table); @Override Partition transformOutboundParti...
@Test public void getDatabasePrefix() throws Exception { databaseMapping.getDatabasePrefix(); verify(metastoreMapping).getDatabasePrefix(); }
DatabaseMappingImpl implements DatabaseMapping { @Override public String getMetastoreMappingName() { return metaStoreMapping.getMetastoreMappingName(); } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping queryMapping); @Override Table transformOutboundTable(Table table); @Override Partition transformO...
@Test public void getMetastoreMappingName() throws Exception { databaseMapping.getMetastoreMappingName(); verify(metastoreMapping).getMetastoreMappingName(); }
DatabaseMappingImpl implements DatabaseMapping { @Override public CacheFileMetadataRequest transformInboundCacheFileMetadataRequest(CacheFileMetadataRequest req) { req.setDbName(metaStoreMapping.transformInboundDatabaseName(req.getDbName())); return req; } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMap...
@Test public void transformInboundCacheFileMetadataRequest() throws Exception { CacheFileMetadataRequest cacheFileMetadataRequest = new CacheFileMetadataRequest(); cacheFileMetadataRequest.setDbName(DB_NAME); CacheFileMetadataRequest result = databaseMapping .transformInboundCacheFileMetadataRequest(cacheFileMetadataRe...
DatabaseMappingImpl implements DatabaseMapping { @Override public FireEventRequest transformInboundFireEventRequest(FireEventRequest rqst) { rqst.setDbName(metaStoreMapping.transformInboundDatabaseName(rqst.getDbName())); return rqst; } DatabaseMappingImpl(MetaStoreMapping metaStoreMapping, QueryMapping queryMapping); ...
@Test public void transformInboundFireEventRequest() throws Exception { FireEventRequest fireEventRequest = new FireEventRequest(); fireEventRequest.setDbName(DB_NAME); FireEventRequest result = databaseMapping.transformInboundFireEventRequest(fireEventRequest); assertThat(result, is(sameInstance(fireEventRequest))); a...
DatabaseMappingImpl implements DatabaseMapping { @Override public ForeignKeysRequest transformInboundForeignKeysRequest(ForeignKeysRequest request) { String parentDbName = request.getParent_db_name() == null ? null : metaStoreMapping.transformInboundDatabaseName(request.getParent_db_name()); String foreignDbName = requ...
@Test public void transformInboundForeignKeysRequest() throws Exception { ForeignKeysRequest foreignKeysRequest = new ForeignKeysRequest(); foreignKeysRequest.setParent_db_name(DB_NAME); foreignKeysRequest.setForeign_db_name(DB_NAME); ForeignKeysRequest result = databaseMapping.transformInboundForeignKeysRequest(foreig...
DatabaseMappingImpl implements DatabaseMapping { @Override public ForeignKeysResponse transformOutboundForeignKeysResponse(ForeignKeysResponse response) { for (SQLForeignKey key : response.getForeignKeys()) { key.setPktable_db(metaStoreMapping.transformOutboundDatabaseName(key.getPktable_db())); key.setFktable_db(metaS...
@Test public void transformOutboundForeignKeysResponse() throws Exception { SQLForeignKey foreignKey = new SQLForeignKey(); foreignKey.setPktable_db(DB_NAME); foreignKey.setFktable_db(DB_NAME); ForeignKeysResponse foreignKeysResponse = new ForeignKeysResponse(Collections.singletonList(foreignKey)); ForeignKeysResponse ...