mirror of
https://github.com/google/nomulus.git
synced 2025-08-05 01:11:50 +02:00
mv com/google/domain/registry google/registry
This change renames directories in preparation for the great package rename. The repository is now in a broken state because the code itself hasn't been updated. However this should ensure that git correctly preserves history for each file.
This commit is contained in:
parent
a41677aea1
commit
5012893c1d
2396 changed files with 0 additions and 0 deletions
|
@ -0,0 +1,189 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.domain.registry.model.billing;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.domain.registry.model.EntityTestCase;
|
||||
import com.google.domain.registry.model.registrar.Registrar;
|
||||
import com.google.domain.registry.testing.ExceptionRule;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
|
||||
import org.joda.money.CurrencyMismatchException;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link RegistrarBillingEntry}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public final class RegistrarBillingEntryTest extends EntityTestCase {
|
||||
|
||||
@Rule
|
||||
public final ExceptionRule thrown = new ExceptionRule();
|
||||
|
||||
@Test
|
||||
public void testIndexing() throws Exception {
|
||||
verifyIndexing(
|
||||
persistResource(
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(null)
|
||||
.setParent(Registrar.loadByClientId("NewRegistrar"))
|
||||
.setCreated(DateTime.parse("1984-12-18TZ"))
|
||||
.setTransactionId("goblin-market")
|
||||
.setDescription("USD Invoice for December 1984")
|
||||
.setAmount(Money.parse("USD 10.00"))
|
||||
.build()),
|
||||
"currency",
|
||||
"created");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetters() throws Exception {
|
||||
RegistrarBillingEntry entry =
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(null)
|
||||
.setParent(Registrar.loadByClientId("NewRegistrar"))
|
||||
.setCreated(DateTime.parse("1984-12-18TZ"))
|
||||
.setTransactionId("goblin-market")
|
||||
.setDescription("USD Invoice for December 1984")
|
||||
.setAmount(Money.parse("USD 10.00"))
|
||||
.build();
|
||||
assertThat(entry.getId()).isEqualTo(1L);
|
||||
assertThat(entry.getParent()).isEqualTo(Key.create(Registrar.loadByClientId("NewRegistrar")));
|
||||
assertThat(entry.getCreated()).isEqualTo(DateTime.parse("1984-12-18TZ"));
|
||||
assertThat(entry.getTransactionId()).isEqualTo("goblin-market");
|
||||
assertThat(entry.getDescription()).isEqualTo("USD Invoice for December 1984");
|
||||
assertThat(entry.getAmount()).isEqualTo(Money.parse("USD 10.00"));
|
||||
assertThat(entry.getBalance()).isEqualTo(Money.parse("USD 10.00"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToJsonMap() throws Exception {
|
||||
assertThat(
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(null)
|
||||
.setParent(Registrar.loadByClientId("NewRegistrar"))
|
||||
.setCreated(DateTime.parse("1984-12-18TZ"))
|
||||
.setTransactionId("goblin-market")
|
||||
.setDescription("USD Invoice for December 1984")
|
||||
.setAmount(Money.parse("USD 10.00"))
|
||||
.build()
|
||||
.toJsonMap())
|
||||
.isEqualTo(
|
||||
new ImmutableMap.Builder<String, Object>()
|
||||
.put("id", 1L)
|
||||
.put("transactionId", "goblin-market")
|
||||
.put("created", "1984-12-18T00:00:00.000Z")
|
||||
.put("description", "USD Invoice for December 1984")
|
||||
.put("currency", "USD")
|
||||
.put("amount", "10.00")
|
||||
.put("balance", "10.00")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBadTimeOrdering_causesError() throws Exception {
|
||||
thrown.expect(IllegalStateException.class, "Created timestamp not after previous");
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(null)
|
||||
.setParent(Registrar.loadByClientId("NewRegistrar"))
|
||||
.setCreated(DateTime.parse("1984-12-18TZ"))
|
||||
.setDescription("USD Invoice for December")
|
||||
.setAmount(Money.parse("USD 10.00"))
|
||||
.build())
|
||||
.setParent(Registrar.loadByClientId("NewRegistrar"))
|
||||
.setCreated(DateTime.parse("1984-12-17TZ"))
|
||||
.setTransactionId("goblin")
|
||||
.setDescription("USD Invoice for August")
|
||||
.setAmount(Money.parse("USD 3.50"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegistrarMismatch_causesError() throws Exception {
|
||||
thrown.expect(IllegalStateException.class, "Parent not same as previous");
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(null)
|
||||
.setParent(Registrar.loadByClientId("NewRegistrar"))
|
||||
.setCreated(DateTime.parse("1984-12-18TZ"))
|
||||
.setDescription("USD Invoice for December")
|
||||
.setAmount(Money.parse("USD 10.00"))
|
||||
.build())
|
||||
.setParent(Registrar.loadByClientId("TheRegistrar"))
|
||||
.setCreated(DateTime.parse("1984-12-17TZ"))
|
||||
.setTransactionId("goblin")
|
||||
.setDescription("USD Invoice for August")
|
||||
.setAmount(Money.parse("USD 3.50"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCurrencyMismatch_causesError() throws Exception {
|
||||
thrown.expect(CurrencyMismatchException.class);
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(null)
|
||||
.setParent(Registrar.loadByClientId("NewRegistrar"))
|
||||
.setCreated(DateTime.parse("1984-12-18TZ"))
|
||||
.setDescription("USD Invoice for December")
|
||||
.setAmount(Money.parse("USD 10.00"))
|
||||
.build())
|
||||
.setParent(Registrar.loadByClientId("NewRegistrar"))
|
||||
.setCreated(DateTime.parse("1984-12-17TZ"))
|
||||
.setTransactionId("goblin")
|
||||
.setDescription("JPY Invoice for August")
|
||||
.setAmount(Money.parse("JPY 350"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZeroAmount_causesError() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Amount can't be zero");
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(null)
|
||||
.setParent(Registrar.loadByClientId("NewRegistrar"))
|
||||
.setCreated(DateTime.parse("1984-12-18TZ"))
|
||||
.setDescription("USD Invoice for December")
|
||||
.setAmount(Money.zero(USD))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyTransactionId_becomeNull() {
|
||||
assertThat(
|
||||
new RegistrarBillingEntry.Builder()
|
||||
.setPrevious(null)
|
||||
.setParent(Registrar.loadByClientId("NewRegistrar"))
|
||||
.setTransactionId("")
|
||||
.setCreated(DateTime.parse("1984-12-18TZ"))
|
||||
.setDescription("USD Invoice for December 1984")
|
||||
.setAmount(Money.parse("USD 10.00"))
|
||||
.build()
|
||||
.getTransactionId())
|
||||
.isNull();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue