Feature #206
Method to determine the next available digital identifier for a given attribute in a directory
| Status: | Closed | Start: | 30/04/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assigned to: | % Done: | 100% |
||
| Category: | Core | |||
| Target version: | 2.0 |
Description
Add a method to determine the next available digital identifier for a given attribute in a directory.
History
Updated by Stéfanie Duprey about 2 years ago
- File NextIntAttributeValueFinder.java added
You will find in attachment a proposition of implementation of this feature, hope it will be useful !
Updated by Stéfanie Duprey about 2 years ago
- File NextIntAttributeValueFinder.java added
I made some corrections and improvement, please find the new file in attachment
Updated by Rémy-Christophe Schermesser about 2 years ago
I have some comments on the source code.
We prefer to have brackets everywhere even for single-lined if. So can you add them ?
You use the method keySet on the Map matchingEntries. The method entrySet is quicker, and why not put a nice foreach instead of a while on an iterator ?
Why did code the class as a factory ? I do not thnik this is useful, because I think it will be used in JavaScript.
At last, where is the unit test ? ;)
Updated by Stéfanie Duprey about 2 years ago
- File NextIntAttributeValueFinder.java added
- File NextIntAttributeValueFinderTest.java added
- File testNextIntAttribute_5438entries.ldif added
Rémy-Christophe Schermesser wrote:
I have some comments on the source code.
ThanksWe prefer to have brackets everywhere even for single-lined if. So can you add them ?
Done (see attachment) You use the method keySet on the Map matchingEntries. The method entrySet is quicker, and why not put a nice foreach instead of a while on an iterator ?
OkWhy did code the class as a factory ? I do not thnik this is useful, because I think it will be used in JavaScript.
I code the class as a singleton not a factory, because we should not have more than one instance of this class running to avoid two simultaneous calls to the method getNextValue. I didn't use a static method because there is some state stored.
How would you have done this ?At last, where is the unit test ? ;)
I give you some and the ldif corresponding, but I need some help to know how to tell the unit test to load the ldif before try the assert (and how to empty the directory for the other test). Could you help me doing this please ?
Thanks a lot for your help.
Updated by Rémy-Christophe Schermesser about 2 years ago
Thanks for the corrections !
But I have some comments on the tests :- We are using JUnit 4, so can you update your test ?
- Why are you using assertTrue and not assertEquals ?
- There is no need to catch the exceptions, you can juste throw them and JUnit will consider is as an error in the test.
I code the class as a singleton not a factory, because we should not have more than one instance of this class running to avoid two simultaneous calls to the method getNextValue. I didn't use a static method because there is some state stored. How would you have done this ?
Sorry, I thought singleton and I wrote factory. I do not like the singleton pattern, it is very difficult to code a good one (with all the problems of concurrency). But, in this case, without Spring, I do not see how to do it.
At last, where is the unit test ? ;)
I give you some and the ldif corresponding, but I need some help to know how to tell the unit test to load the ldif before try the assert (and how to empty the directory for the other test). Could you help me doing this please ?
If I remember correcty, you just have to put your ldif in this file src/test/java/org/lsc/opends/test.ldif and it will be loaded in the OpenDS. If it does not work, try GrosSeb or jooooooon on irc.
Thanks !
Updated by Stéfanie Duprey about 2 years ago
- File NextIntAttributeValueFinderTest.java added
Rémy-Christophe Schermesser wrote:
Thanks for the corrections !
But I have some comments on the tests :
- We are using JUnit 4, so can you update your test ?
- There is no need to catch the exceptions, you can juste throw them and JUnit will consider is as an error in the test.
I've first done my test case as you ask me, but then I saw the other test made in the lsc-project and I rewrote my test to fit your coding style... but OK, see attachmentsI code the class as a singleton not a factory, because we should not have more than one instance of this class running to avoid two simultaneous calls to the method getNextValue. I didn't use a static method because there is some state stored. How would you have done this ?
Sorry, I thought singleton and I wrote factory. I do not like the singleton pattern, it is very difficult to code a good one (with all the problems of concurrency). But, in this case, without Spring, I do not see how to do it.
At last, where is the unit test ? ;)
I give you some and the ldif corresponding, but I need some help to know how to tell the unit test to load the ldif before try the assert (and how to empty the directory for the other test). Could you help me doing this please ?
If I remember correcty, you just have to put your ldif in this file src/test/java/org/lsc/opends/test.ldif and it will be loaded in the OpenDS. If it does not work, try GrosSeb or jooooooon on irc.
But I need two different states (empty directory and full directory), and I can't put two ldif in one. We can not state the ldif to import in the test itself ?Thanks !
Updated by Rémy-Christophe Schermesser about 2 years ago
I've first done my test case as you ask me, but then I saw the other test made in the lsc-project and I rewrote my test to fit your coding style... but OK, see attachments
Thanks for updating the tests !
But I need two different states (empty directory and full directory), and I can't put two ldif in one. We can not state the ldif to import in the test itself ?
Then I think you should go and see the OpenDS API, because I don't think we have a test that does that. You also can mock some interfaces and not having any ldiff. It is as you wish !
Thanks !
Updated by Sébastien Bahloul 4 months ago
- Status changed from New to Closed
- Target version changed from 1.3.x branch to 2.0.x branch
This is now handled through Sequences in a smarter way.
Updated by Clément OUDOT about 1 month ago
- Target version changed from 2.0.x branch to 2.0
- % Done changed from 0 to 100