/integration-tests/debezium/src/main/java/org/apache/camel/quarkus/component/debezium/common/it/DebeziumMongodbResource.java

https://github.com/apache/camel-quarkus · Java · 75 lines · 49 code · 10 blank · 16 comment · 2 complexity · 4cdb79ab71c83b84dc53a995c86c4c89 MD5 · raw file

  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.apache.camel.quarkus.component.debezium.common.it;
  18. import javax.enterprise.context.ApplicationScoped;
  19. import javax.inject.Inject;
  20. import javax.ws.rs.GET;
  21. import javax.ws.rs.Path;
  22. import javax.ws.rs.Produces;
  23. import javax.ws.rs.core.MediaType;
  24. import org.eclipse.microprofile.config.Config;
  25. @Path("/debezium-mongodb")
  26. @ApplicationScoped
  27. public class DebeziumMongodbResource extends AbstractDebeziumResource {
  28. @Inject
  29. Config config;
  30. public DebeziumMongodbResource() {
  31. super(Type.mongodb);
  32. }
  33. @Path("/receiveAsRecord")
  34. @GET
  35. @Produces(MediaType.APPLICATION_JSON)
  36. public Record receiveAsRecord() {
  37. return super.receiveAsRecord();
  38. }
  39. @Path("/receive")
  40. @GET
  41. @Produces(MediaType.TEXT_PLAIN)
  42. public String receive() {
  43. return super.receive();
  44. }
  45. @Path("/receiveOperation")
  46. @GET
  47. @Produces(MediaType.TEXT_PLAIN)
  48. public String receiveOperation() {
  49. Record record = receiveAsRecord();
  50. if (record == null) {
  51. return null;
  52. }
  53. return record.getOperation();
  54. }
  55. @Override
  56. String getEndpoinUrl(String hostname, String port, String username, String password, String databaseServerName,
  57. String offsetStorageFileName) {
  58. return Type.mongodb.getComponent() + ":localhost?"
  59. + "offsetStorageFileName=" + offsetStorageFileName
  60. + "&mongodbUser=" + config.getValue(Type.mongodb.getPropertyUsername(), String.class)
  61. + "&mongodbPassword=" + config.getValue(Type.mongodb.getPropertyPassword(), String.class)
  62. + "&mongodbName=docker-rs"
  63. + "&mongodbHosts=" + hostname + ":" + port;
  64. }
  65. }