here is the class in which we are writing code when an attcahment is created following logic should run.the test class that i had written had a code coverage of 63%.test class pasted below.need help to improve code coverage: public class WFG_ContentDocumentTriggerHelper {     public static void validateDocumentTitle( List&lt;ContentDocument&gt; documentList ){         Set&lt;String&gt; titleSet = new Set&lt;String&gt;();                 Map&lt;String,ContentDocument&gt; title_doc_map = new Map&lt;String,ContentDocument&gt;();         for( ContentDocument doc : documentList ){             if(doc.ContentAssetId != null){             titleSet.add( doc.Title );             title_doc_map.put( doc.Title, doc );                         }         }         List&lt;ContentDocument&gt; existingDoc = [Select id,Title,ContentAssetId from ContentDocument where Id not IN: documentList and Title IN: titleSet];         for( ContentDocument doc : existingDoc ){             if( doc.Id != title_doc_map.get(doc.Title).Id &amp;&amp; title_doc_map.get(doc.Title).ContentAssetId != NULL ){                 title_doc_map.get(doc.Title).addError('Duplicate Title for Asset, Document title already exists with another Asset.');             }         }     }  }  test class that i wrote: @isTest public class WFG_ContentDocumentTriggerHelperTest {     @isTest     static void validateDocumentTitleTest() {         Blob b = Blob.valueOf('Unit Test Attachment Body');         ContentVersion cv1 = new Contentversion();         cv1.title = 'ABC';         cv1.PathOnClient = 'test';         cv1.versiondata = EncodingUtil.base64Decode('Unit Test Attachment Body');         insert cv1;         ContentVersion cv2 = new Contentversion();         cv2.title = 'ABC';         cv2.PathOnClient = 'test';         cv2.versiondata = EncodingUtil.base64Decode('Unit Test Attachment Body');         insert cv2;         System.assertNotEquals(null, cv2.Id);     } }
This is a canonical question and answer developed by the community to help address common questions. If you've been directed here, or your question has been closed as a duplicate, please look through the resources here and use them to shape more specific questions. To browse all canonical questions and answers, including more unit test resources, navigate to the  tag.  This canonical question is intended to address several classes of common questions by providing a quick summary and links to comprehensive resources:   How is code coverage obtained and calculated? How do I increase my coverage?  Why can't I cover these lines? Why isn't the body of my loop or conditional statement covered?
What is accountsd and why does it want to use the "login" keychain? The latex file coding is not there but the pdf file is there I wrote all my coding in the .tex file. The next day when I opened it the coding is all gone and the pdf file is opening with it and is displayed as an output. How do I bring back my coding? I've started using the dashicon fonts in my theme options page for WP 3.8+ users. To take care of users on &lt; 3.8, I've added the dashicon fonts to my theme folder and also an entry at the top of my custom admin stylesheet:  @font-face {     font-family: 'dashicons';     src: url('fonts/dashicons.eot'); }  @font-face {         font-family: 'dashicons';         src: url(data:application/x-font-woff;charset=utf-8;base64,xxx) format('woff'),         url('fonts/dashicons.ttf') format('truetype'),         url('fonts/dashicons.svg#dashicons') format('svg');     font-weight: normal;     font-style: normal; }   (I've left out the base64 encode for brevity)  This works great, however, I'm getting a bit of strange behavior with the fonts. When I leave the admin open in a tab and go away for a bit, then come back, every once in a while, the webfonts have turned to squares, as if the font is missing.  This does not happen every time. It appears to be somewhat random.  In those cases, simply doing a mouseover the page usually returns the webfonts to their proper symbols.  The screenshots below show the issue. The first screenshot is what I see when the problem occurs. The second screenshot is what I'm expecting to see when things go well.   Notice in the first shot, how the wordpress labels themselves have gone to a default serif font. How do you write (and run) a correct micro-benchmark in Java?  I'm looking for some code samples and comments illustrating various things to think about.  Example: Should the benchmark measure time/iteration or iterations/time, and why?  Related: What exactly are genes, DNA and chromosomes. How do they relate to each other and what is their function? So I am new to biology and I have been reading, and searching the web, but I couldn't understand the whole framework of a cell. So as I understood:    A DNA, is a double chain of Nucleotides (A,T,G,C and a sugar) and a phosphate residue. Some parts of a DNA code a gene and some do not, exons and introns accordingly. As I understand it these the sequences of exons hold genes and the whole sequence is called genome. Now I read in the book Introduction to Computational Molecular Biology by J. C. Setubal and J. Meidanis. that I cite Each cell of an organism has a few very long DNA molecules. Each such molecule is called a chromosome. So each X shaped thing called a chromosome holds one DNA molecule?   Or is each "hand" of the chromosome one complete double helix of DNA so we have 23 pairs of such chromosomes? or is it that each we 23 pairs Xs?   Shouldn't we have just one uniquely identifiable DNA sequence? I am asking this, because I have also read that each chromosome encodes a different part of one's genome. Does this mean we have several DNA sequences?   This is really bothering me, since I can't figure out the correct structure of a cell.   EDIT: Now if each chromosome contains a pair of DNA helices. We have 46 chromosomes so overall within the cell there are 92 DNA sequences? All of which are the same? Or are they different? If they are different how do they code for different aspects of one's genome? Ball $X^*$ is weak-star metrizable iff X is separable in Conway's book. This is a Theorem in Conway's book     I don't understand in the third paragraph why there are open sets $\{U_n:n\geq1\}$ in $(ball X^*,wk^*)$ such that $0\in U_n$ and $\bigcap^{\infty}_{n=1}U_n=\{0\}$. By the definition of the relative weak-star topology on ball $X^*$, for each $n$, there exists a finite set $F_n$ contained in $X$ such that $$\{x^*\in\text{ball }X^*:|\langle x,x^*\rangle|&lt;1 \text{ for all }x\in F_n\}\subseteq U_n.$$  Can someone explain this for me？ Thank you so much!! How do I start Nautilus as root? I've got a problem with Nautilus in Ubuntu 12.04 LTS.  When I run the command gksu nautilus /, the password ask box appears and I type my super-user password, then the password box disappears and Nautilus is not opened.  When I try to open Nautilus as a normal user in with the command nautilus, the folder is opened.  When I try in terminal   $ sudo nautilus   I got the following error  $ sudo nautilus /  ** (nautilus:8523): WARNING **: Command line `dbus-launch --autolaunch=2c8ce9b7da2257c2609b749700000007 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n Could not parse arguments: Cannot open display:   How can I fix this error? How to to resize an ext4 partition from the command line? What's the easiest way to resize an ext4 partition (or any type partition depending on the method) from the command line (potentially with the fewest commands, but also the easiest to understand)?  Using a tool like Gparted is obviously easy in a GUI, but what about in the command line? I guess text-based GUIs can count for the answer too since it's technically still in the command line. It just needs to be easy.  By partition I mean a simple partition on a single disk of a personal computer (e.g. on a laptop). For example, I want to resize /dev/sda4. There's no RAIDs, there's not more than one disk drive, there's not anything complicated here. Just a simple partition on a single disk (/dev/sdaX on /dev/sda). How can you use optional parameters in C#? Note: This question was asked at a time when C# did not yet support optional parameters (i.e. before C# 4).  We're building a web API that's programmatically generated from a C# class. The class has method GetFooBar(int a, int b) and the API has a method GetFooBar taking query params like &amp;a=foo &amp;b=bar.   The classes needs to support optional parameters, which isn't supported in C# the language. What's the best approach? How do I read from /proc/$pid/mem under Linux? The  tells me that /proc/$pid/mem “can be used to access the pages of a process's memory”. But a straightforward attempt to use it only gives me  $ cat /proc/$$/mem /proc/self/mem cat: /proc/3065/mem: No such process cat: /proc/self/mem: Input/output error   Why isn't cat able to print its own memory (/proc/self/mem)? And what is this strange “no such process” error when I try to print the shell's memory (/proc/$$/mem, obviously the process exists)? How can I read from /proc/$pid/mem, then? How can I abort a running JDBC transaction? Is there a way to prematurely abort a transaction? Say, I have sent a command to the database which runs five minutes and after four, I want to abort it.  Does JDBC define a way to send a "stop whatever you are doing on this connection" signal to the DB? There are infinitely many prime numbers $p$ for which $p + 2$ and $p + 4$ are also prime numbers I need help with this question: There are infinitely many prime numbers $p$ for which $p + 2$ and $p + 4$ are also primes.  Where should I start? what proof techniques will be useful?  Any input will be very useful to me. Gravity in 2d space and inverse linear law In our three-dimensional universe, gravity obeys the inverse square law. In a four-dimensional universe, gravity would be expected to obey the inverse cube law et cetera.  In a two-dimensional universe, one would similarly expect gravity to obey an inverse linear law. I've seen it claimed that this is not actually true, when you work it out according to general relativity there would actually be no gravity at all in such a universe. Is this true? If so, is there a layman's explanation of why? Is it related to the fact that gravitational potential wells would be infinitely deep?  Would electrostatic forces follow the same law as gravity?  If there existed infinitely long strings in our universe, would they have the same gravitational effect as point particles in a 2d universe? Prove the function is continuous, exercise from Conway's "Functions of One Complex Variable I" Has the wall been repaired? of Stack Overflow, all content posted on Stack Exchange sites by their users (i.e. you wonderful people) has been provided to the whole universe under . For my fellow non-lawyers, that license basically means:   Anyone can use any Stack Exchange posts at any time without having to ask for permission Making money off of the copied content is permitted You don't even have to copy stuff from here verbatim; you can just use it as a starting point and make whatever edits you want There are just two rules you have to follow:   You have to provide . Simple links to the original post and author info are just fine. You have to  and allow other people to use your content, as long as they follow these very same rules. How meta!    (If you ever forget any of that, and want to refresh your memory, the license info is linked to in the footer of every page.)  There are, in fact, a lot of people who republish varying amounts of our content for assorted reasons. Unfortunately, there are some Stack Content Republishers Attributing Poorly and/or Excelling at Ranking (SCRAPERs, for short).  In this context, "attributing poorly" means any use that doesn't follow our attribution rules or make any other reasonable attempt at give credit. This can get pretty egregious; I've seen SCRAPERs that not only don't link back to SE originals, but also use fake author info and post dates to make it harder to find originals. By "excelling at ranking," I'm referring to copycat sites that end up higher in Google results than the original SE sites do for the same content. That's not necessarily wrong, but in some cases, it indicates inappropriate SEO hackery.  So, the question is: what can you do if you spot a SCRAPER? I am trying to retrieve list items using date range based on date column. It implicit both 'Fromdate' and 'Todate'.My CAML query is also querying on two other conditions as well. I am using the below query but it is not retrieving the data.when I remove the date range from query data is retrieved fine. But i want date range as well in my query how would i do this. Little help would work for me.   camlQuery.set_viewXml('&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;And&gt;&lt;And&gt;&lt;Neq&gt;&lt;FieldRef Name="ID" /&gt;&lt;Value Type="Number"&gt;0&lt;/Value&gt;&lt;/Neq&gt;&lt;Eq&gt;&lt;FieldRef Name="_ModerationStatus" /&gt;&lt;Value Type="ModStat"&gt;0&lt;/Value&gt;&lt;/Eq&gt;&lt;Geq&gt;&lt;FieldRef Name="Created" /&gt;&lt;Value Type="DateTime"&gt;' + fromDate + '&lt;/Value&gt;&lt;/Geq&gt;&lt;Leq&gt;&lt;FieldRef Name="Created" /&gt;&lt;Value Type="DateTime"&gt;' + toDate + '&lt;/Value&gt;&lt;/Leq&gt;&lt;/And&gt;&lt;/And&gt;&lt;/Where&gt;&lt;OrderBy&gt;&lt;FieldRef Name="_ModerationStatus" Ascending="True" /&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;/View&gt;'); Why does demand for stock rise when a company appears to have high future value? So a company decides to raise money by selling shares of its stock. The stock is offered at an initial price of their determination. The stock is then traded in a market where forces of supply and demand, as well as speculation, affect its price.  When a company performs well (or makes decisions that will likely increase the company's earnings in the future), more people want to buy that stock than do people wanting to sell it. This creates demand for that stock which causes its sell/bid prices rise. When a company performs poorly, the opposite occurs; more people want to sell the stock than want to buy. This creates a surplus that causes sell/bid prices to fall.  Understanding this, people speculate over company performance to determine the future behavior of a stock, and attempt to "buy low, sell high" or "borrow high, return low" in order to make a profit.  But my question is regarding the first part of that process. What is it about company performance that causes the perceived value of its stock to rise? This is especially perplexing since I would guess that most people don't exercise their voting rights, and many stocks don't pay dividends.  It's not like a shareholder has any direct financial gains from increased company earnings (speculative stock pricing notwithstanding).  What is the intrinsic value of the stock?  It seems to me that all participants in a stock market tacitly agree that stock price will have a direct correlation with company performance. So another way of asking the question is, would an opposite agreement hold? What financially (this isn't a question about logistics, communication, or feasibility) stops all participants in a market from agreeing to value a particular company's stock inversely with respect to the company's performance?  Since I feel like I can't quite nail down my question, another form of it would be, why is stock market behavior driven by company performance? What is Attribute Based Encryption? What is the difference between "Have you seen this?" and "Did you see this?" What's the difference between these two phrases?