I have a Spring Boot v1.5.14.RELEASE app., Using Spring Initializer, JPA, embedded Tomcat and following the RESTful API architecture principes. I have created this test
#Test
public void createCustomerChain() throws Exception {
this.mockMvc.perform(post("/customer/createCustomer")
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content("{\n" +
" \"subSegment\":\"25\",\n" +
" \"legalLanguage\":\"NL\",\n" +
" \"isRestrictel\":true,\n" +
" \"isCommunicationLanguageForAllAccount\":true,\n" +
" \"isAntiMarketing\":true,\n" +
" \"hotelChain\":{\n" +
" \"legalForm\":\"09\",\n" +
" \"foundationDate\":\"2001-12-17T09:30:47Z\",\n" +
" \"tradingName\":\"COMPANY NAME\",\n" +
" \"printName\":\"TEST PRINT\",\n" +
" \"naceCode\":\"16230\",\n" +
" \"vatNumber\":\"41223334343\", \n" +
" \"countryVatCode\":\"IN\",\n" +
" \"isSubjectToVAT\":true,\n" +
" \"sectorCode\":\"85\",\n" +
" \"legalAddress\": {\n" +
" \"mainkey\":2088512,\n" +
" \"subkey\":3256\n" +
" }\n" +
" },\n" +
" \"isVATNumberOnBill\":true,\n" +
" \"communicationLanguage\":\"EN\"\n" +
"}"))
.andExpect(status().isOk())
.andDo(document("customer-create-request-Chain",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
responseFields(
fieldWithPath("billingAccountId").description("The billing account id of the newly created customer"),
fieldWithPath("paymentAgreementId").description("The Payment Agreement Id of the newly created customer"),
fieldWithPath("customerId").description("The id of the new created customer"),
fieldWithPath("isNewlyCreated").description("Set to `true` when the customer is newly created")),
requestFields(
fieldWithPath("subSegment").description("Market subsegment"),
fieldWithPath("legalLanguage").description("Legal language"),
fieldWithPath("isAntiMarketing").description("If true, customer does not want to have any marketing contact"),
fieldWithPath("isRestrictel").description("Indicates that the customer is on the orange list. Do not disclose information to other companies for commercial purposes."),
fieldWithPath("hotelChain.legalAddress.mainkey").description("LAM mainkey of the address. If the mainkey and the subkey is given the rest of the address information is not needed."),
fieldWithPath("hotelChain.legalAddress.subkey").description("LAM subkey of the address"),
fieldWithPath("hotelChain.legalForm").description("Legal form"),
fieldWithPath("hotelChain.foundationDate").description("Date of the foundation of a company(mandatory field for 'Chain' customer type)"),
fieldWithPath("hotelChain.vatNumber").description("Enterprise or VAT number"),
fieldWithPath("hotelChain.countryVatCode").description("ISO2 country code of the VAT number"),
fieldWithPath("isVATNumberOnBill").description("Indicates if the VAT number will be shown on the bill"),
fieldWithPath("hotelChain.isSubjectToVAT").description("Indicates if the enterprise number is a real VAT or not"),
fieldWithPath("hotelChain.sectorCode").description("Subtitle Description. Additional information relating to the customer. Name-Value pairs"),
fieldWithPath("hotelChain.tradingName").description("Trading name"),
fieldWithPath("hotelChain.printName").description("Print name of the customer"),
fieldWithPath("hotelChain.naceCode").description("Nace code"),
fieldWithPath("communicationLanguage").description("Communication language"),
fieldWithPath("isCommunicationLanguageForAllAccount")
.description("If true, commercial language of all BGC billing accounts receive the value defined at customer level and users not allowed to change commercial language of any billing account"))));
}
and this is the result of running the test:
org.springframework.restdocs.snippet.SnippetException: Fields with the following paths were not found in the payload: [customerId]
and removing the customerId from fieldWithPath test passed successfully but, I wonder why I don't have the same error for such a field like billingAccountId
This is due to customerId field could be null or absent in some cases. You can use optional for it:
fieldWithPath("customerId").description("Description").optional()
To find a more precise reason, please, post the code of the createCustomer() method.
Related
I want to iterate through my discord's voices channels and get their members.
But my code (below) isn't working as expected.
for (VoiceChannel voiceChannel : event.getJDA().getGuildById(Config.guildId).getVoiceChannelCache()) {
System.out.println("-> " + voiceChannel.getName() + " -->> " + voiceChannel.getMembers().size());
}
However I put it after a ReadyEvent, so I don't know why it isn't working
I am trying to create a dynamic link in an email which am sending out using Spring Jpa. I created a variable in my application.properties file so that whenever I am pushing to server I can easily change that variable from localhost to the domain name for live deployment. However, when I try to pass the domain name value, the link becomes inactive. I would appreciate if you could point me in the right direction.
Here is the application.properties snippet below:
server.port=8008
spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://41.207.248.189:xxxx/xxx
spring.datasource.username=****
spring.datasource.password=****
##GMAIL PROPERTIES
senderEmail = xxxxx
spring.mail.host=xxxx
spring.mail.port=xxx
spring.mail.username=xxxxxx
spring.mail.password=xxxxxxx
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.ssl.trust=xxxxxxx
domain-name=localhost:4200
spring.jpa.show-sql=true
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
Here is the snippet for the a href I need to pass the domain-name into:
"\n" +
"<a href='{domain-name}/payments/"+hashlink+"' target='_blank'>Click Here</a>"+
"\n" +
This approach above is not working but when I pass the link manually, the "click here" link works:
"<a href='http://127.0.0.1:4200/payments/"+hashlink+"' target='_blank'>Click Here</a>"+
I would appreciate your help. Thanks
UPDATE
Below is the html for the email body where I am setting the domain-name
try {
emailService.sendEmail("PAYMENT NOTIFICATION",
"<p>Dear sir/ma,</p>\n" +
"\n" +
"\n" +
"<h4>LETTER OF NOTICE </h4>\n" +
"\n" +
"\n" +
"<p>This is to notify you of the status of your organisation ..... </p>\n" +
"<p>You are hereby put on notice to remit the outstanding amount on or before ....</p>\n" +
"<p>Kindly follow the link below to make....\n</p>\n" +
"\n" +
"<a href='{domain-name}/payments/"+hashlink+"' target='_blank'>Click Here</a>"+
"\n" +
"\n" +
"<p>Thank you.</p> \n" +
"\n"
, org.getEmail());
} catch (
MessagingException e) {
e.printStackTrace();
} catch (Exception e) {
System.out.println("Email Service error");
e.printStackTrace();
}
}
I hope this helps... I look forward to getting a solution. Thanks.
Based on the comments/discussion here's what you need to do:
Read/Inject the property to a String variable using #Value
#Value("${domain-name}") String domainName;
Use the variable to construct your href
Full code:
application.properties
domain-name=www.abc.com
DomainNameApp:
package domainname;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.*;
#SpringBootApplication
public class DomainNameApp {
public static void main(String[] args) {
SpringApplication.run(DomainNameApp.class, args);
}
}
#RestController
class Ctrl {
#Value("${domain-name}")
String domainName; // or use constructor injection
#GetMapping("a")
void a() {
String hashlink = "jsdklfsdklflsdf";
String html = "<p>" +
"<a href='" + domainName + "/payments/" + hashlink + "' target='_blank'>Click Here</a>" +
"</p>";
System.out.println(html);
}
}
Based on answers by #gtiwari333... I made some corrections to my code. I decided to detail the changes I made for future readers.
First of all, I added http:// to the parameter in my application.properties, as below:
domain-name=http://localhost:4200
next, I added #Value annotation to the top of my class as below:
#Value("${domain-name}")
String domainName;
Then I was able to pass it into the a href link with ease as below:
"<p>Kindly follow the link below to make....\n</p>\n" +
"\n" +
"<a href='" +domainName+ "/payments/payment-make" + link + "' target='_blank'>Click Here</a>" +
"\n" +
"\n" +
"<p>Thank you.</p> \n" +
"\n"
Thanks. I give credit to #gtiwari333 for helping me with this.
In SAS Open Metadata reference (page 126), it says:
The UpdateMetadata method enables you to update the properties of existing metadata objects. It returns an error if the metadata object to be updated does not exist, unless the OMI_IGNORE_NOTFOUND (134217728) flag is set.
Here is my problem, if I specify the flag or I don't specify the flag, I still get the same error: ("SASLibrary : A5X8AHW1.B40000SQ cannot be found in the wlibrary container in the Foundation repository.")
Here is a snippet that reproduces the error:
import com.sas.meta.SASOMI.IOMI;
import com.sas.metadata.MetadataUtil;
import org.omg.CORBA.StringHolder;
IOMI iOMI = ... // an instance of IOMI connection
StringHolder outputMeta = new StringHolder();
String request = ""
+ "<UpdateMetadata>"
+ " <Metadata>"
+ " <SASLibrary Id=\"A5X8AHW1.B40000SQ\"/>"
+ " </Metadata>"
+ " <NS>SAS</NS>"
+ " <Flags>" + (MetadataUtil.OMI_IGNORE_NOTFOUND | MetadataUtil.OMI_TRUSTED_CLIENT | MetadataUtil.OMI_RETURN_LIST) + "</Flags>"
+ " <Options/>"
+ "</UpdateMetadata>"
;
iOMI.DoRequest(request, outputMeta);
Any ideas what is going wrong?
Contrary to what that document states, I have only seen OMI_IGNORE_NOTFOUND flag work with the DeleteMetadata method.
The javadoc also seems to support this by stating
OMI_IGNORE_NOTFOUND (134217728) This flag is for DeleteMetadata to tell it to ignore objects not found so that it will not return on error.
com.sas.metadata.remote.MdOMIUtil Interface Field Summery
I have a GUI related question. I am attempting to use create a GUI using a JOptionsPane as well as JPanel, JText and JLabel. Now that I have accomplished building my GUI and getting the tag to work my next goal is to create a table around the formatted text of my GUI, I will post my code below to illustrate:
String css = "<span style='font-size:10; color: white; background-color:black'>";
String batchCss = "<span style='font-size: 20'>";
String cssBorder = "<span style='border:1px dotted red'>";
String endSpanCss = "</span>"; String table = "
<table border=4>"; String endTable = "</table>"; String text = "
<html>" + table + css + batchCss + "1 of 2" +endSpanCss+ endSpanCss + endTable + "
<br>Entry Detail:" + "
<br>11111111111111111111111111+ "
<br>
<br>Please type 1-21 to apply a reason code and addenda record to the entry detail." + "
<br>Please type 'h' and press any button to open the help screen." + "
<br>
<br>
<br>Reason Codes" + "
<br>R01 - Insufficient Funds" + "
<br>R02 - Account Closed" + "
<br>R03 - No Account" + "
<br>R04 - Invalid Account Number" + "
<br>R05 - Unauthorized Debit to Consumer Account" + "
<br>R06 - Returned per ODFI Request" + "
<br>R07 - Auth Revoked by Customer" + "
<br>R08 - Payment Stopped" + "
<br>R09 - Uncollected Funds" + "
<br>R10 - Customer Advises Not Authorized" + "
<br>R11 - Check Truncation Entry Return" + "
<br>R12 - Branch Sold to Another DFI" + "
<br>R13 - Invalid ACH Routing Number" + "
<br>R14 - Represenative Payee Deceased or Unable to Continue" + "
<br>R15 - Beneficiary or Account Holder Deceased" + "
<br>R16 - Account Frozen" + "
<br>R17 - File Record Edit Criteria" + "
<br>R18 - Improper Effective Entry Date" + "
<br>R19 - Account Field Error" + "
<br>R20 - Non-Transaction Amount" + "
<br>R21 - Invalid Company Information" + "
<br>R22 - Invalid Individual ID Number";
Someone yesterday got me started with the CSS which works, but now I need to figure out how to put some type of table around the whole thing so I can organize this text-heavy dialog. I have tried to use a CSS tag like <span style='border:1px dottec red'> as you can see from my variables, but this had no effect.
When I add the standard HTML table tag outside the CSS it works however my CSS no longer works (as you can see if you test the program). Removing the table border will again allow the CSS to work.
How can I get the span style='border' to work, or how can I get the table border to work with the CSS?
EDITED:
Here is additionally runnable code as requested.
package nacha;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Testing4
{
public static void main(String args[]){
String css = "<span style='font-size:10; color: white; background-color:black'; border:>";
String batchCss = "<span style='font-size: 20'>";
String endSpanCss = "</span>";
String table = "<table border=4>";
String endTable = "</table>";
String mainCss = "<span style='font-size:12; color: red'>";
String header1Css = "<span style = 'font-size:15; font-weight:bold;text-decoration:underline;border:1px dotted red'>";
String text1Css = "<span style = 'font-size:12; font-style:italic'>";
String text = "<html>" +
css + batchCss + "1 of 2"+endSpanCss+endSpanCss+ endSpanCss +
"<br><br><br>"+header1Css+"Entry Detail:"+endSpanCss +
"<br>"+mainCss+"111111111111111111111"+endSpanCss+
"<br><br><br>"+text1Css+"Please type 1-21 to apply a reason code and addenda record to the entry detail." +
"<br>Please type 'h' and press the next entry button to open the help screen."+endSpanCss +
"<br><br><br>"+header1Css+"Reason Codes"+ endSpanCss +
"<br>"+table+"R01 - Insufficient Funds" +
"<br>R02 - Account Closed" +
"<br>R03 - No Account" +
"<br>R04 - Invalid Account Number" +
"<br>R05 - Unauthorized Debit to Consumer Account" +
"<br>R06 - Returned per ODFI Request" +
"<br>R07 - Auth Revoked by Customer" +
"<br>R08 - Payment Stopped" +
"<br>R09 - Uncollected Funds" +
"<br>R10 - Customer Advises Not Authorized" +
"<br>R11 - Check Truncation Entry Return" +
"<br>R12 - Branch Sold to Another DFI" +
"<br>R13 - Invalid ACH Routing Number" +
"<br>R14 - Represenative Payee Deceased or Unable to Continue" +
"<br>R15 - Beneficiary or Account Holder Deceased" +
"<br>R16 - Account Frozen" +
"<br>R17 - File Record Edit Criteria" +
"<br>R18 - Improper Effective Entry Date" +
"<br>R19 - Account Field Error" +
"<br>R20 - Non-Transaction Amount" +
"<br>R21 - Invalid Company Information" +
"<br>R22 - Invalid Individual ID Number"+endTable;
//Below code creates the GUI for the return builder portion of the program.
Object[] options1 = {"Next Entry","Next Batch","Finished"};//Changes the default buttons.
BorderLayout border = new BorderLayout();
JPanel panel = new JPanel();
panel.setLayout(border);
panel.add(new JLabel(text),BorderLayout.NORTH);//Adds the label to the top of the panel.
JTextField textField = new JTextField(10);
panel.add(textField,BorderLayout.SOUTH);//Adds a user-input text area to the bottom of the panel.
int result = JOptionPane.showOptionDialog(null, panel, "Return Builder", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options1, JOptionPane.YES_OPTION);
}
}
You will find the line giving me trouble is:
String header1Css = "<span style = 'font-size:15; font-weight:bold;text-decoration:underline;border:1px dotted red'>";
I have set that line to have a 1 px dotted red border. That format string is called here:
"<br><br><br>"+header1Css+"Entry Detail:"+endSpanCss +
And the result is the "Entry Detail:" line is formatted correctly for everything except the border.
Solved.
What I was trying to accomplish is not currently possible as the border is not used for rendering.
Source:
http://docs.oracle.com/javase/8/docs/api/javax/swing/text/html/CSS.html
Thanks Sva.MU for assisting with this.
I am trying to pull all issues (resolved or not) from the current sprint and display that information. I am using a JIRA REST Java client to achieve this. I am quite new to JIRA and the JRJC so would like all the help I can get really.
This is the code I have written so far:
SearchResult allIssuesInSprint = restClient.getSearchClient().searchJql("sprint = \"" + 29 + "\" order by rank").claim();
Iterable<Issue> allIssues = allIssuesInSprint.getIssues();
for (Issue issue : allIssues) {
System.out.println("Key: " + issue.getKey());
System.out.println("Type: " + issue.getIssueType());
System.out.println("Status: " + issue.getStatus());
System.out.println("Priority: " + issue.getPriority());
}
Again, I am new to JIRA's JAR files, so I'm not certain on how to use them. Any help would be appreciated.